SQL Server insert bulk 插入数据到数据库,能不能触发插入触发器,我测试的是不能,但不知道原因。求知 100
触发器:USE[xxxx]GO/******Object:Trigger[dbo].[tableInsert]ScriptDate:2018/11/7星期三上午11:09...
触发器:
USE [xxxx]
GO
/****** Object: Trigger [dbo].[tableInsert] Script Date: 2018/11/7 星期三 上午 11:09:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[tableInsert]
ON [dbo].[table]
AFTER INSERT
AS
BEGIN
declare @TaskID char(36)
declare @UserID varchar(20)
declare @datastr varchar(4000)
declare cur_Insert cursor for select * from inserted
open cur_Insert
fetch cur_Insert into @TaskID,@UserID
while @@FETCH_STATUS=0
begin
--更新任务表状态,启动发短信线程
update SendTask set UserID='0' where TaskID=@TaskID
fetch next from cur_Insert into @TaskID,@UserID
end
close cur_Insert
deallocate cur_Insert
END 展开
USE [xxxx]
GO
/****** Object: Trigger [dbo].[tableInsert] Script Date: 2018/11/7 星期三 上午 11:09:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[tableInsert]
ON [dbo].[table]
AFTER INSERT
AS
BEGIN
declare @TaskID char(36)
declare @UserID varchar(20)
declare @datastr varchar(4000)
declare cur_Insert cursor for select * from inserted
open cur_Insert
fetch cur_Insert into @TaskID,@UserID
while @@FETCH_STATUS=0
begin
--更新任务表状态,启动发短信线程
update SendTask set UserID='0' where TaskID=@TaskID
fetch next from cur_Insert into @TaskID,@UserID
end
close cur_Insert
deallocate cur_Insert
END 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询