Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Delete data from all user tables

Author  Topic 

swatib
Posting Yak Master

173 Posts

Posted - 2006-06-26 : 08:18:42
Hello

I wanted to delete data from all the databse user tables.
How this is possible in sql server?

Please explain in details

Thanks


Njoy Life

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-06-26 : 08:24:18
Begin with
sp_msforeachtable 'select count(*) from ?'


Then move on to
sp_msforeachtable 'truncate table ?'



Peter Larsson
Helsingborg, Sweden
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-26 : 08:39:54
>>sp_msforeachtable 'truncate table ?'

You will get error if there is referential integrity between tables

Instead of Delete, truncate them
Refer this
http://sqlteam.com/forums/topic.asp?TOPIC_ID=65341

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-06-26 : 13:54:05
"Instead of Delete, truncate them"

You been up all night Madhi? I think you mean the other way round ...

Kristen
Go to Top of Page

swatib
Posting Yak Master

173 Posts

Posted - 2006-06-27 : 01:45:48
Many thanks to all of you!!!

Njoy Life
Go to Top of Page
   

- Advertisement -