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)
 generate Sql script for accessing tables

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-12-10 : 07:47:45
kailas writes "hi all

i want to delete contains of all tables present in current DB trough script .... plz help me....."

Andraax
Aged Yak Warrior

790 Posts

Posted - 2004-12-10 : 08:18:44
Hello!

You can do that using dynamic SQL and the INFORMATION_SCHEMA view. Another option is to use the sp_MSforeachtable procedure.

/Andraax
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-12-10 : 10:35:48
select 'delete ' + name from sysobjects where xtype = 'u'

then run the script.
You might want to try truncate table instead.
Or might be easier just to create a new empty database.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -