1. OUTPUT ... INTO
用于将一条记录从表一移动到表二时非常好用,常见于备份记录的应用
例一:
DELETE [TableUseing] OUTPUT * INTO [TableBak] |
例二:(用于移动时修改某字段的值)
DELETE [TableUseing] OUTPUT Field1, Field2, GETDATE() INTO [TableBak] |
2.表变量
用于存储临时的查询结果
DECLARE @tmp TABLE (ID INT, CITY NVARCHAR(50)) INSERT INTO @tmp SELECT MIN(ID), CITY FROM [TableTest] WITH(NOCLOCK) GROUP BY CITY |