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 Development (2000)
 DELETE and TRUNCATE a table variable

Author  Topic 

johnsql
Posting Yak Master

161 Posts

Posted - 2007-08-16 : 10:35:39
I declare a table variable as
declare @t table(id int, first_value int, second_value int)

In some middle steps, I insert some rows for that table var, and use TRUNCATE TABLE @t statement to empty it for faster performance. But I fail with error like "Incorrect syntax near '@t' " and I must use DELETE FROM @t statement instead.
I am using SQL server 2000 and open the book online about "truncate" and "table variables", I find no words about the relations of TRUNCATE and table variables.

Any idea would be appreciated.

Thanks in advance.
johnsql

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-08-16 : 10:37:55
you can't use truncate table on table variable. use DELETE


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -