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)
 truncating rows in all tables with a procedure

Author  Topic 

rkpamidi
Starting Member

5 Posts

Posted - 2001-07-07 : 00:49:32
I have a problem with the procedure to truncate rows in all the tables of a database. Please find the procedure below and
suggest a solution for the problem.
Are there any other ways of doing this?

CREATE procedure timetable_truncate
@tabname varchar(50)=""
as
declare cur cursor for
select name from timetable..sysobjects where type='U' order by name
open cur
fetch cur into @tabname
while(@@fetch_status =0)
begin
truncate timetable..[@tabname]
fetch cur into @tabname
end
close cur
deallocate cur

   

- Advertisement -