SQL SERVER – UTILITY

Conteggio righe di ogni tabella

exec sp_MSforeachtable @command1="select TableName='?', Rows=count(*) from ?;"

Elenco tabelle con Identity

select COLUMN_NAME, TABLE_NAME

from INFORMATION_SCHEMA.COLUMNS

where TABLE_SCHEMA = 'dbo'

and COLUMNPROPERTY(object_id(TABLE_NAME), COLUMN_NAME, 'IsIdentity') = 1

order by TABLE_NAME

Truncate di tutte le tabelle

EXEC sp_MSForEachTable 'TRUNCATE TABLE ?'