INSERT TRIGGER problems: "Key column information is insufficient or incorrect. Too many rows were affected by update."
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
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)
精彩评论