1. OUTPUT ... INTO
用于將一條記錄從表一移動(dòng)到表二時(shí)非常好用,常見(jiàn)于備份記錄的應(yīng)用
例一:
DELETE [TableUseing]
OUTPUT *
INTO [TableBak]
例二:(用于移動(dòng)時(shí)修改某字段的值)
DELETE [TableUseing]
OUTPUT Field1, Field2, GETDATE()
INTO [TableBak]
2.表變量
用于存儲(chǔ)臨時(shí)的查詢結(jié)果
DECLARE @tmp TABLE (ID INT, CITY NVARCHAR(50))
INSERT INTO @tmp
SELECT MIN(ID), CITY
FROM [TableTest] WITH(NOCLOCK)
GROUP BY CITY
更多信息請(qǐng)查看IT技術(shù)專欄