June 1, 2006 at 2:56 am
I would like to create a procedure that will truncate a table by a given name passed by parameter
create procedure ds_truncatetable(@tablename varchar(60))
as
//code goes here
go
Thanx
June 1, 2006 at 3:10 am
create procedure ds_truncatetable(@tablename varchar(60))
as
exec ('truncate table '+@tablename)
go
------------
Prakash Sawant
http://psawant.blogspot.com
June 1, 2006 at 3:36 am
Note that if the table has referential integrity constraints then you cannot just "truncate" it, even if it is technically empty. you'll have to use delete from [tablename] in that case.
Odd requirement to want to truncate a table based on its name - perhaps DB not designed well?
June 1, 2006 at 5:58 am
Thanx alot Prakash Sawant and Ian Yates
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply