You can audit a table and see index growth for all tables in a database (this example uses the Northwind database) without the use of cursors. Use the query

sp_MSforeachtable @command1="print '?'", @command2=
   "sp_MStablespace @name = '?'"

The result of the query is

[dbo].[Employees]
RowsDataSpaceUsedIndexSpaceUsed
--------------------------------------
923256
[dbo].[Categories]
RowsDataSpaceUsedIndexSpaceUsed
--------------------------------------
811240

If you want to use multiple commands, you can specify the commands by using @command1 through @command3. You can use up to three commands per query in sp_MSforeachtable.

End of Article




You must log on before posting a comment.

If you don't have a username & password, please register now.

 
 

ADS BY GOOGLE