Mass Update on Table with Trigger
am 29.06.2007 22:20:04 von paulmac106
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
Re: Mass Update on Table with Trigger
am 29.06.2007 23:04:30 von tu_wstaw_moje_imie
paulmac106@gmail.com wrote:
> 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
Re: Mass Update on Table with Trigger
am 29.06.2007 23:29:29 von Erland Sommarskog
(paulmac106@gmail.com) writes:
> 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@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downlo ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books .mspx