Thursday, January 15, 2009

Update View Definition

There could be a situation when you update the underlying base tables but view definitions are not updated. In order to update the view metadata for the specified non-schemabound view, use the following:

sp_refreshview [ @viewname = ] 'viewname'

Wednesday, January 14, 2009

Check total number of records (count(*)) in each table

If you want to check the total number of records in each table of a database, run the following query:

USE
Go
EXEC sp_MSForEachTable 'SELECT count(*) FROM ?'