Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Table Variable

Author  Topic 

Posting Yak Master

103 Posts

Posted - 2009-03-18 : 03:58:15
I am using a Table Variable in My stored Procedure. The stored procedure is too long. I need this Table variable in early part of the stored procedure only. How can I clean up the Table variable after I finished using it? I dont want it to exist untill stored procedure finishes.

Rahul Shinde

Posting Yak Master

115 Posts

Posted - 2009-03-18 : 04:21:12
for this purpose you better use temporary table...

Thanks, Vadym
MCITP DBA 2005/2008
Chief DBA at
Go to Top of Page

Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-03-18 : 04:26:38
You can't. The table variable is there for the scope of entire stored procedure.
You can however do a DELETE FROM @MyTableVariableNameHere if you want to empty the table.

E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

- Advertisement -