sql server trigger for update

作者在 2017-03-16 15:18:41 发布以下内容

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: 20170316
-- Description: <Description,,>
-- =============================================
if (object_id('update_qy_info', 'TR') is not null)
    drop trigger update_qy_info
go
create trigger update_qy_info on qy_info
for update
AS 
declare @qian varchar(50);
declare @hou varchar(50);
DECLARE cursor_qian_qy_info cursor for select mc+lx as ml from deleted;
DECLARE cursor_hou_qy_info cursor for select mc+lx from inserted;
open cursor_qian_qy_info
open cursor_hou_qy_info


BEGIN
fetch next from cursor_qian_qy_info into @qian
while @@FETCH_STATUS = 0 
begin
insert into dbo.logs values(@qian)
fetch next from cursor_qian_qy_info into @qian
end
close cursor_qian_qy_info
close cursor_hou_qy_info
deallocate cursor_qian_qy_info
deallocate cursor_hou_qy_info
END
GO

-------------------------------- 以下内容补充于 2017-03-16 15:22:45 --------------------------------

0HMSAL6LF4DNX(@HY(~F)XI.png (上传于2017-03-16 15:22:45)
0HMSAL6LF4DNX(@HY(~F)XI.png
sql_server | 阅读 1951 次
文章评论,共0条
游客请输入验证码