时间:2021-07-01 10:21:17 帮助过:21人阅读
INSERT INTO TestTB(Province,City) output inserted.Province, inserted.City VALUES(‘广东‘,‘深圳‘)
delete from TestTB output deleted.* where id=1
UPDATE TestTB SET Province = ‘湖南‘,City=‘郴州‘ OUTPUT ‘我来自(更新前)‘+ DELETED.Province+DELETED.City as [Before] ,‘我来自(更新后)‘ + Inserted.Province+Inserted.City as [After] WHERE id=1
DECLARE @temp TableTABLE( idint, Provincevarchar(50), Cityvarchar(50) )DELETEFROMTestTB OUTPUT deleted.*INTO@tempTableWHEREid>4SELECT*FROM@tempTable-- 返回更新前的值 UPDATE ppdai_jr_shop.dbo.GeneratorUniqueNo SET suffix=suffix+2 OUTPUT Inserted.suffix WHERE prefix=‘PPDTK‘ -- 返回更新后的值 UPDATE ppdai_jr_shop.dbo.GeneratorUniqueNo SET suffix=suffix+2 OUTPUT DELETED.suffix WHERE prefix=‘PPDTK‘
SQL执行并返回执行前/后结果
标签:tab bsp nbsp 变量 dai eid declare before har