Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Truncation date (not truncating a date)

Author  Topic 

dmilam
Posting Yak Master

185 Posts

Posted - 2012-08-03 : 12:37:07
Is there a T-SQL solution to the problem of when a table was truncated, or is this something to be found only in a log file?

Or, is a table's modify_date also an indicator of when a table was truncated?

My current guess:


SELECT
OBJECT_NAME(id)
,rowmodctr
,rowcnt
,[truncated] =
CASE
WHEN (rowmodctr = rowcnt) THEN 'Yes'
WHEN (rowmodctr > rowcnt) THEN 'No'
ELSE ''
END
,[accumulations] =
rowmodctr - rowcnt
,t.modify_date
FROM
sys.sysindexes
JOIN
sys.tables t ON t.object_id = id
WHERE
rowmodctr > 0
ORDER BY
OBJECT_NAME(id);
GO
   

- Advertisement -