dbTalk Databases Forums  

Mass Update on Table with Trigger

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Mass Update on Table with Trigger in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
paulmac106@gmail.com
 
Posts: n/a

Default Mass Update on Table with Trigger - 06-29-2007 , 03:20 PM






Hi,

I need to update a field in about 20 records on a table. The table has
an update trigger (which updates the [lastedited] field whenever a
record is updated). As a result I'm getting an error: "Subquery
returned more than 1 value.", and the update fails.

Is there a way in the stored procedure to handle this issue?

thanks for your help.

Paul


Reply With Quote
  #2  
Old   
Marcin A. Guzowski
 
Posts: n/a

Default Re: Mass Update on Table with Trigger - 06-29-2007 , 04:04 PM






paulmac106 (AT) gmail (DOT) com wrote:
Quote:
Hi,

I need to update a field in about 20 records on a table. The table has
an update trigger (which updates the [lastedited] field whenever a
record is updated). As a result I'm getting an error: "Subquery
returned more than 1 value.", and the update fails.

Is there a way in the stored procedure to handle this issue?
That's not an issue - it's pure ignorance. Probably someone assumed,
that only one record can be updated at a time. Trigger logic (if the
trigger is causing this error) must be changed to handle true set-based
operations.

--
Best regards,
Marcin Guzowski
http://guzowski.info


Reply With Quote
  #3  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Mass Update on Table with Trigger - 06-29-2007 , 04:29 PM



(paulmac106 (AT) gmail (DOT) com) writes:
Quote:
I need to update a field in about 20 records on a table. The table has
an update trigger (which updates the [lastedited] field whenever a
record is updated). As a result I'm getting an error: "Subquery
returned more than 1 value.", and the update fails.

Is there a way in the stored procedure to handle this issue?
If you are not able to correct the trigger, you will have to run a
cursor to updaet one row at a time. But obviously that should be a very
last resort.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.