最佳答案
Is it possible to truncate or flush out a table variable in SQL Server 2008?
declare @tableVariable table
(
id int,
value varchar(20)
)
while @start <= @stop
begin
insert into @tableVariable(id, value)
select id
, value
from xTable
where id = @start
--Use @tableVariable
--@tableVariable should be flushed out of
-- old values before inserting new values
set @start = @start + 1
end