SQL Server RowVersion/Timestamp – Comparisons

From MSDN: Each database has a counter that is incremented for each insert or update operation that is performed on a table that contains a rowversion column within the database. This counter is the database rowversion. This tracks a relative time within a database, not an actual time that can be associated with a clock. … Read more

Select all empty tables in SQL Server

On SQL Server 2005 and up, you can use something like this: ;WITH TableRows AS ( SELECT SUM(row_count) AS [RowCount], OBJECT_NAME(OBJECT_ID) AS TableName FROM sys.dm_db_partition_stats WHERE index_id = 0 OR index_id = 1 GROUP BY OBJECT_ID ) SELECT * FROM TableRows WHERE [RowCount] = 0 The inner select in the CTE (Common Table Expression) calculates … Read more