新手请教:这个触发器怎么写?

FlyingQQ 2003-11-05 12:44:05
我有一个通用信息表,保存诸如民族、政治成分等信息,我设计了三个字段ID,Value,Type分别保存编号、内容和类别编码,其中类别编码为(00)的为通用信息的类别,我要根据类别编码来调用一个存储过程,我该如何获取这个被修改记录的类别编码?我是新手,还望高手能帮帮忙,贴点代码学习学习!
...全文
45 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zjcxc 元老 2003-11-05
  • 打赏
  • 举报
回复
create trigger t_update on 表
for update
as
declare tb cursor for select type from inserted
declare @type varchar(50)
open tb
fetch next from tb into @type
while @@fetch_status=0
begin
exec 要调用的存储过程 @type
fetch next from tb into @type
end
close tb
deallocate tb
go
pengdali 2003-11-05
  • 打赏
  • 举报
回复
declare cursor_insert cursor for select Type from 通用信息表
declare @i varchar(100)
open cursor_insert
fetch cursor_insert into @i
while @@fetch_status=0
begin
exec 调用一个存储过程 @i
fetch cursor_insert into @i
end
close cursor_insert
deallocate cursor_insert

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧