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 出现错误。。。。。。
在线等,,,,,急啊。。。。。。。。。。。。。。
展开
 我来答
roy_88
2011-12-22 · TA获得超过3696个赞
知道大有可为答主
回答量:2914
采纳率:100%
帮助的人:2748万
展开全部
--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
splaybow
2011-12-22 · TA获得超过488个赞
知道小有建树答主
回答量:941
采纳率:0%
帮助的人:729万
展开全部
晕,我从来没有这样用过, 我一直是使用inserted来代表新插入的那一行。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式