Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 623
  • Last Modified:

MS SQL 2008 Trigger Problem

Hi,

I have a MS SQL 2008 table called tblActivistm which has various fields including a PK field of activist_id

I have created the following trigger:

CREATE TRIGGER trgUpdateActivist
ON dbo.tblActivist
FOR UPDATE
AS
INSERT INTO RMay.tblTriggers (table_name, action, table_id)
SELECT 'Activist', 'U', activist_id
FROM INSERTED

The trigger is created sucesfully.

If I issue a query to update the record, then the query suceeds, and the trigger does it's job.

If I open tblActivist in Visual Studio and change a entry interactivly, I get the following error when I try to save the change:

No row was updated.

The data in row 29 was not committed.
Error Source: Microsoft.VisualStudio.DataTools
Error Message: The row value(s) updated or deleted either do not make the row unique or they alter multiple rows(2 rows).

Correct the errors and retry or press ESC to cancel the change(s).




How do I fix this?



Thanks,

Richard
0
rpm
Asked:
rpm
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
please  try this change to the trigger:

CREATE TRIGGER trgUpdateActivist
ON dbo.tblActivist
FOR UPDATE
AS
SET NOCOUNT ON
INSERT INTO RMay.tblTriggers (table_name, action, table_id)
SELECT 'Activist', 'U', activist_id
FROM INSERTED

Open in new window

0
 
rpmAuthor Commented:
Perfect!

Thank you very much.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now