|
|
| |

How do I perform the same actions for all tables in a database?
Answer:
If you need to perform the same actions for all tables in a database,
you can create cursor or you can use the sp_MSforeachtable
undocumented stored procedure to accomplish the same goal with less work.
For example, you can use the sp_MSforeachtable stored procedure
to rebuild all indexes in a database:
EXEC sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?')"
See also these links:
SQL Server 2000 Useful undocumented stored procedures
SQL Server 7.0 Useful undocumented stored procedures
|
|
|