INSERT TRIGGER 问题:“键列信息不足或不正确。太多行受到更新的影响。”
我的 TRIGGER 遇到一些问题:
CREATE TRIGGER "tblSettingTable_INSERT"
ON dbo.tblSettingTable
FOR INSERT
AS
INSERT INTO dbo.tblSettingReportParameter (tableName, columnName, columnCaption)
SELECT tableName = CAST(OBJECT_NAME(c.object_id) AS varchar(100)),
columnName = CAST(c.name AS varchar(100)),
columnCaption = CAST(ex.value AS varchar(100))
FROM sys.columns c
LEFT OUTER JOIN sys.extended_properties ex
ON ex.major_id = c.object_id
AND ex.minor_id = c.column_id
AND ex.name = 'MS_Caption'
INNER JOIN inserted ON OBJECT_NAME(c.object_id) = inserted.tableName
WHERE OBJECTPROPERTY(c.object_id, 'IsMsShipped')=0
AND OBJECT_NAME(c.object_id) = inserted.tableName
我正在尝试从表中获取一些列属性并将其插入到 dbo.tblSettingReportParameter 中,但我遇到了这个问题:“关键列信息不够或不正确。太多行受到更新的影响。”
我做错了什么?使用 MS-SQL 2008 RS。
谢谢,
斯特凡
I am having some problems with my TRIGGER:
CREATE TRIGGER "tblSettingTable_INSERT"
ON dbo.tblSettingTable
FOR INSERT
AS
INSERT INTO dbo.tblSettingReportParameter (tableName, columnName, columnCaption)
SELECT tableName = CAST(OBJECT_NAME(c.object_id) AS varchar(100)),
columnName = CAST(c.name AS varchar(100)),
columnCaption = CAST(ex.value AS varchar(100))
FROM sys.columns c
LEFT OUTER JOIN sys.extended_properties ex
ON ex.major_id = c.object_id
AND ex.minor_id = c.column_id
AND ex.name = 'MS_Caption'
INNER JOIN inserted ON OBJECT_NAME(c.object_id) = inserted.tableName
WHERE OBJECTPROPERTY(c.object_id, 'IsMsShipped')=0
AND OBJECT_NAME(c.object_id) = inserted.tableName
I am trying the get some column properties from a table and INSERT it into dbo.tblSettingReportParameter
but I get this thrown at my face: "Key column information is insufficient or incorrect. Too many rows were affected by update."
What am I doing wrong? Using MS-SQL 2008 RS.
Thanks,
Stefan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您将
SET NOCOUNT ON
添加到触发器,则应该修复此问题。返回的 xx 行
使 Access 感到困惑(我假设它会根据问题的标签向 SQL Server 发出 INSERT)Should be fixed if you add
SET NOCOUNT ON
to the trigger.The
xx rows returned
is confusing Access (which I assume issues the INSERT to SQL Server of course based on the tags for the question)