SQL Update statement

Hi all,

Sorry for this super newbie question, but I am purely a mysql developer.

I am trying to update a table using Query Analyzer and am having problems with the sql syntax.

This is what I'm trying to do:

update table
set column1 = 'test data',
column2 = 'test data2'
where column1 is NULL and column2 is NULL

I receive 512 errors, stating that the subquery cannot return more than 1 record. I understand that most of the table has nulls in column 1 and 2, and need to update all columns with these attributes.

Please help.



Answer this question

SQL Update statement

  • Firestorm353

    Hi,

    this sounds like the old story. Somebody wrote a trigger and wasn’t aware that triggers are fired by statement not per rows. so like in your case if your are doing an update which will affect multiple rows and the trigger is n’t prepared to handle multiple rows, you will get an error. o you have a trigger on that table (I assume yes :-) )

    HTH, Jens Suessmeyer.

    ---
    http://www.sqlserver2005.de
    ---


  • anthonyjl

    Thanks for the reply.

    Looked up the table, and yes I have a trigger. Is there any quick way to bypass trigger just for this update


  • AntC999

    Hi,

    just for completion, disabling triggers is:

    ALTER TABLE TableName DISABLE TRIGGER ALL which can be found in the BOL


    HTH, Jens Suessmeyer.

    ---
    http://www.sqlserver2005.de
    ---


  • ChrisWall

    SOLVED.

    Thanks for heading me in the right direction.

    Cheers,


  • SQL Update statement