Script generator to fetch all table's record count

Posted by Bandi under Sql Server category on | Points: 40 | Views : 707
Below SQL generates the SELECT Script to get the record count of each table in a database.

This type of script is very useful to prepare a report after database refreshment and data migration

SELECT  'Select ''' + DB_NAME() + '.' + SCHEMA_NAME(SCHEMA_ID) + '.'
+ LEFT(, 128) + ''' as DatabaseName, count(*) as RecordCount From ' +
+ ';' AS ' Script generator to know the record count of each table in current database'
FROM sys.objects o
WHERE o.[type] = 'U'

Comments or Responses

Login to post response