Thursday, 30 November 2006

sp_MSforeachtable (Undocumented Stored Procedure)

Loops though all tables in a database, repeating the specified command on each one.

The question mark represents the table name, examples are ;
sp_MSforeachtable @command1='print ''?'' dbcc checktable (''?'')'

sp_MSforeachtable @command1='print ''?'' truncate table [''?'']'

You can issue up to three commands to the stored procedure using parameters @command1 through @command3.

No comments: