【发布时间】:2014-02-26 15:52:22
【问题描述】:
是否可以在 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
【问题讨论】:
-
您到底想完成什么?如果您只是要再次冲洗它们,为什么还要插入任何东西?
-
插入在这里只是象征性的。实际操作要复杂得多,涉及到很多其他的表
-
有评论
--Use @tableVariable估计是用来做一些计算的,没有附上 -
是的.. 它将用于一些计算.. 请不要与 USE
混淆
标签: sql sql-server tsql