[dba-SQLServer] ?s on sp_MSForEachTable

Susan Harkins ssharkins at gmail.com
Tue Jan 13 11:03:54 CST 2009


I ran the following statement against a copy of AdventureWorks, expecting to 
see some constraint errors:

EXEC sp_MSForEachTable 'DELETE FROM ?'

Instead, the command was completely successfully -- by message, but of 
course, no data was deleted, which is what the statement should do -- delete 
all the records from every table in the database. Of course, I didn't expect 
it to work because of the constraints, but I did expect to see some kind of 
error message.

It's an undocumented sp and despite my efforts to figure this out, I'm not 
finding any help. I've found a lot of information on the different arguments 
and how it's supposed to run, but answers to the above question -- why not 
error message -- can't find that sort of information.

Is anyone familiar with this sp?

Susan H.





More information about the dba-SQLServer mailing list