Subquery returned more than 1 value. Error on Update SQL

  • Hello good people,

    Need help with this update query statement. I am trying to update multiple records with this update query. It looks something like this:

    update <table> set <field> = 'uniqueindentifier type' where <another field> = 'uniqueidentifier type'

    I have tried this query on other tables with success, however I keep getting this "Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. The statement has been terminated." error on this particular table. Can anybody shed some light?

    Johnny

  • cabrerajm (1/25/2011)


    Hello good people,

    Need help with this update query statement. I am trying to update multiple records with this update query. It looks something like this:

    update <table> set <field> = 'uniqueindentifier type' where <another field> = 'uniqueidentifier type'

    I have tried this query on other tables with success, however I keep getting this "Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. The statement has been terminated." error on this particular table. Can anybody shed some light?

    Johnny

    First of all, from your description, it appears that a subquery is returning more than one row.

    Second, we really can't help you very much as we simply can't see from here what you see from there. For real help, please read the first article I reference below in my signature block and follow those instructions regarding what you should post for the best answers. Also, be sure to include expected results based on the sample data you will need to post.

  • Ooops! Forgot the trigger behind that table:hehe: That solved my problem:-)

  • If the problem was in a trigger, then you probably have a problem with that trigger. A trigger should never fail due to more than 1 record being returned in a sub-query. This is bad coding practice in a trigger.

    I have seen many triggers that assume only 1 insert/update is occurring at a time. This works fine as long as the application front end does the insert/update. When you try to insert/update the table using a DML query then you have problems. It's best to fix the trigger so that it will work in either case.

    Todd Fifield

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply