Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 update query error

Author  Topic 

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2011-09-23 : 10:31:52
Hi Team,
can you correct me if my query is wrong...


UPDATE TASK SET TASK__ID = NULL

Thanks in advance...

my aim is to make all the values in this column as null.


Arnav
Even you learn 1%, Learn it with 100% confidence.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-09-23 : 10:34:06
it is correct so far...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-23 : 10:34:39
this is correct. just check it

select count(*) from TASK WHERE TASK_ID IS NULL


this count should be same as actual table count

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2011-09-23 : 10:39:48
Hi Team,
there is a trigger on this column. may be that is the reason i'm getting the below error. please suggest me.

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.


Arnav
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-23 : 10:42:22
yep. its error from trigger. my guess is you're trying to populate a variable with contents from inserted/deleted and since your update is set based there are multiple records in them which is why this error.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-09-23 : 10:43:16
we suggest you to show the table structure and the trigger code...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -