最近做东西使用了一些触发器,感觉有些时候使用触发器操作比单纯的使用代码要容易,简捷。

Create trigger [触发器名]  on [dbo].[表名1] for insert as
declare @getid int; --定义一个整形
declare @url varchar(50);--定义一个字符
set @getid=(select id from inserted);--查询刚插入数据ID,并赋值给定义的变量@getid。
set @url='person.aspx?id='+cast(@getid as varchar(50))--将整形转换为字符,并赋值给定义的变量@url。
update 表名1 set url=@url where id=@getid 修改数据操作。

相关文章:

  • 2021-12-05
  • 2021-09-03
  • 2022-12-23
  • 2022-12-23
  • 2022-03-14
  • 2022-12-23
  • 2021-07-19
  • 2021-12-05
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案