|
|
Here’s a simple query that shows you how to dynamically pass a Table Name to the TRUNCATE TABLE command
USE YOURDB
GO
DECLARE @tbl varchar(30) = 'YourTableName'
DECLARE @dynSQL varchar(50)
SET @dynSQL = 'TRUNCATE TABLE ' + @tbl
EXEC (@dynSQL)
You can even create a Stored Procedure and use this code. The only difference will be that ‘YourTableName’ will get replaced with a parameter of the StoredProcedure containing the Table Name
Did you like this post?
|
|
|
||
|
|
|
|
|
|
|
subscribe via rss |
|
subscribe via e-mail |
|
|
print this post |
|
follow me on twitter |






comments
0 Responses to "Dynamically Pass a Table Name to TRUNCATE TABLE"Post a Comment