我有一个名为insert2Newsletter的参数存储过程
(@sex nvarchar(10),@f_name nvarchar(50),@l_name nvarchar(70),@email nvarchar(75),@ip_address nvarchar(50),@hotelID int,@maArt nchar(2))
我想将这个存储过程称为插入式触发器.如何从插入中检索相应的字段,如何在触发器中调用insert2Newsletter?
我没有成功尝试:
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TRIGGER RA2Newsletter ON [dbo].[Reiseagent] AFTER INSERT AS DECLARE @rAgent_Name nvarchar(50),DECLARE @rAgent_Email nvarchar(50),DECLARE @rAgent_IP nvarchar(50),DECLARE @hotelID int BEGIN SET NOCOUNT ON; -- Insert statements for trigger here Select @rAgent_Name=rAgent_Name,@rAgent_Email=rAgent_Email,@rAgent_IP=rAgent_IP,@hotelID=hotelID From Inserted EXEC insert2Newsletter '','',@rAgent_Name,@rAgent_Email,rAgent_IP,@hotelID,'RA' END GO
thx很多为您的反馈…问候…
解决方法
最后…
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO ALTER TRIGGER [dbo].[RA2Newsletter] ON [dbo].[Reiseagent] AFTER INSERT AS declare @rAgent_Name nvarchar(50),@rAgent_Email nvarchar(50),@rAgent_IP nvarchar(50),@retval int BEGIN SET NOCOUNT ON; -- Insert statements for trigger here Select @rAgent_Name=rAgent_Name,@rAgent_IP,'RA',@retval END