SQL server 2005 中触发器怎么引用新加入的行
--================================================--TemplategeneratedfromTemplateExpl...
-- ================================================
-- Template generated from Template Explorer using:
-- Create Trigger (New Menu).SQL
--
-- Use the Specify Values for Template Parameters
-- command (Ctrl-Shift-M) to fill in the parameter
-- values below.
--
-- See additional Create Trigger templates for more
-- examples of different Trigger statements.
--
-- This block of comments will not be included in
-- the definition of the function.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE TRIGGER ADD_QUESTON
ON TEST_QUESTION
AFTER INSERT
REFERENCES new row nr
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
PRINT 'THANK YOU FOR YOUR ADDITION OF QUESTION!'
INSERT ADD_QUESTION (TCH_ID,TEST_NUM,ADD_TIME)
SELECT 0000000,TEST_NUM,0000-00-00
FROM TEST_QUESTION
WHERE nr.TEST_NUM=TEST_QUESTION.TEST_NUM
PRINT 'SUCCESS!'
PRINT 'THANS!'
-- Insert statements for trigger here
END
GO
其中REFERENCES new row nr 出现错误。。。。。。
在线等,,,,,急啊。。。。。。。。。。。。。。 展开
-- Template generated from Template Explorer using:
-- Create Trigger (New Menu).SQL
--
-- Use the Specify Values for Template Parameters
-- command (Ctrl-Shift-M) to fill in the parameter
-- values below.
--
-- See additional Create Trigger templates for more
-- examples of different Trigger statements.
--
-- This block of comments will not be included in
-- the definition of the function.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE TRIGGER ADD_QUESTON
ON TEST_QUESTION
AFTER INSERT
REFERENCES new row nr
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
PRINT 'THANK YOU FOR YOUR ADDITION OF QUESTION!'
INSERT ADD_QUESTION (TCH_ID,TEST_NUM,ADD_TIME)
SELECT 0000000,TEST_NUM,0000-00-00
FROM TEST_QUESTION
WHERE nr.TEST_NUM=TEST_QUESTION.TEST_NUM
PRINT 'SUCCESS!'
PRINT 'THANS!'
-- Insert statements for trigger here
END
GO
其中REFERENCES new row nr 出现错误。。。。。。
在线等,,,,,急啊。。。。。。。。。。。。。。 展开
2个回答
展开全部
--REFERENCES new row nr去掉
CREATE TRIGGER ADD_QUESTON
ON TEST_QUESTION
AFTER INSERT
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
PRINT 'THANK YOU FOR YOUR ADDITION OF QUESTION!'
INSERT ADD_QUESTION (TCH_ID,TEST_NUM,ADD_TIME)
SELECT 0000000,TEST_NUM,0000-00-00
FROM TEST_QUESTION
WHERE nr.TEST_NUM=TEST_QUESTION.TEST_NUM
PRINT 'SUCCESS!'
PRINT 'THANS!'
-- Insert statements for trigger here
END
CREATE TRIGGER ADD_QUESTON
ON TEST_QUESTION
AFTER INSERT
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
PRINT 'THANK YOU FOR YOUR ADDITION OF QUESTION!'
INSERT ADD_QUESTION (TCH_ID,TEST_NUM,ADD_TIME)
SELECT 0000000,TEST_NUM,0000-00-00
FROM TEST_QUESTION
WHERE nr.TEST_NUM=TEST_QUESTION.TEST_NUM
PRINT 'SUCCESS!'
PRINT 'THANS!'
-- Insert statements for trigger here
END
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询