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
 General SQL Server Forums
 New to SQL Server Programming
 SQL Server

Author  Topic 

sbadam9
Starting Member

1 Post

Posted - 2006-07-21 : 11:08:32
Hi frinds...
i am new to SQL Server...i hve a situation of SQL server Database consists more than 500 different tables in single Db. i want to delete complete data(records) from all tables at once...
What is the best way to get this one done...
thank...i ll be very happy..recieve suggestion..
thanks
Srinivas
Business Analyst.
Pls reply...

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-07-21 : 11:10:50
My Suggestion :
Take a backup first (in case)
Script the tables (drop / create) with indexes ...., run the script.

Srinika
Go to Top of Page

DMWCincy
Starting Member

11 Posts

Posted - 2006-07-21 : 15:17:03
The faster way is what Srinika but for the fun of it you can do this also:

declare @name varchar(100)

set nocount on

Declare table_cursor Cursor
for
select name from sysobjects
where xtype = 'U'


open table_cursor

fetch next table_cursor into
@name
while @@fetch_status = 0
begin
exec 'truncate table ' + @name

fetch next table_cursor into
@name
end
Go to Top of Page
   

- Advertisement -