因需求的关系需要将修改的值返回,故查了些资料发现了OUTPUT这个好东西,现记录下来以防以后忘记 

使用例子: 
1.对于INSERT,可以引用inserted表以查询新行的属性. 
   insert into [表名] (a) OUTPUT Inserted.a values ('a')      
2.对于DELETE,可以引用deleted表以查询旧行的属性. 
   delete [表名] OUTPUT deleted.a where links = 'a' 
3.对于UPDATE,使用deleted表查询被更新行在更改前的属性,用inserted表标识被更新行在更改后的值. 
   update [表名] set a = 'b' OUTPUT Inserted.a where a = 'a'(返回修改后的值) 
   update [表名] set a = 'b' OUTPUT deleted.a where a = 'a' (返回修改前的值) 

相关文章:

  • 2022-02-19
  • 2022-12-23
  • 2021-10-16
  • 2021-08-15
  • 2022-01-29
  • 2021-09-22
猜你喜欢
  • 2022-03-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-16
  • 2021-08-20
相关资源
相似解决方案