• subscribe
October 29, 1999 04:48 PM

Exercise

SQL Server Pro
InstantDoc ID #7514

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.



ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here