sql - SQL Server 2008 中截断/清除表变量

标签 sql sql-server tsql

是否可以在 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 

最佳答案

删除所有内容

DELETE FROM @tableVariable

关于sql - SQL Server 2008 中截断/清除表变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22046487/

相关文章:

sql-server - SQL Server - 当前用户名

sql-server - 从作业执行 sp_send_dbmail 失败,查询结果作为文件附加

sql - 如何在现有表中创建代理键列?

SQL 在日期之间选择

php - SQL Server 的插入忽略的替代方案

sql - 循环遍历列 SQL 以选择多个年份

用于获取格式为 "column heading: column value"的单个记录的 SQL 查询

SQL RANK() 与 ROW_NUMBER()

mysql - MySQL 中的存储和查询时间

sql - 左外连接查询