[dba-SQLServer] ?s on sp_MSForEachTable

Arthur Fuller fuller.artful at gmail.com
Wed Jan 14 09:32:59 CST 2009


Frankly I have never tried that. But I will build a test db using the fab
data generator tool from Red Gate and manufacture some related tables and
then repeat your exercise and see what happens.

IMO Tim's stuff is superior to the built-in procedure since he extends it
beyond tables, to include objects of any type.

I will get back to you on this later today.

A.

On Wed, Jan 14, 2009 at 8:55 AM, Susan Harkins <ssharkins at gmail.com> wrote:

> Maybe you can help. When I run the following statement
>
> EXEC sys.sp_MSForEachTable 'DELETE FROM ?'
>
> I should get an error on tables with constraints to other tables.
> Interesting, when I run TRUNCATE TABLE, I see those errors. With DELETE
> FROM, I see a message that the statement's been completed successfully
> instead of seeing the expected error messages for related tables. Should I
> see an error message for these tables or does it just happily delete what
> it
> can and ignore the tables it can't?
>
> Susan H.
>
>
>



More information about the dba-SQLServer mailing list