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.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Table Variable
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

103 Posts

Posted - 03/18/2009 :  03:58:15  Show Profile  Reply with Quote
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 - 03/18/2009 :  04:21:12  Show Profile  Visit heavymind's Homepage  Send heavymind an ICQ Message  Reply with Quote
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 - 03/18/2009 :  04:26:38  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000