December 18, 2007 at 2:49 pm
I have this simple update query...
update CEM_smcsAssignments
set MGR =
(SELECT a.MGR
FROM #ADD a, CEM_smcsAssignments c
WHERE a.SSN = c.OWNbr)
I want to get the data from one table, and update the other table. I get this error.
Server: Msg 512, Level 16, State 1, Line 1
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.
December 18, 2007 at 3:47 pm
Unlike Oracle or other RDBMS's, you can do this in SQL Server...
UPDATE CEM_smcsAssignments
SET MGR = a.MGR
FROM #ADD a,
CEM_smcsAssignments c
WHERE a.SSN = c.OWNbr
If it'll make you feel better, you can also do this...
UPDATE c
SET MGR = a.MGR
FROM #ADD a,
CEM_smcsAssignments c
WHERE a.SSN = c.OWNbr
--Jeff Moden
Change is inevitable... Change for the better is not.
December 28, 2007 at 1:56 am
Christine M (12/18/2007)
I have this simple update query...update CEM_smcsAssignments
set MGR =
(SELECT a.MGR
FROM #ADD a, CEM_smcsAssignments c
WHERE a.SSN = c.OWNbr)
I want to get the data from one table, and update the other table. I get this error.
Server: Msg 512, Level 16, State 1, Line 1
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.
Note that If you use Jeff Moden's code,if there are more than one value then the first/last(not sure which one) returned value would be assigned
Failing to plan is Planning to fail
December 28, 2007 at 8:21 am
[/quote]
Note that If you use Jeff Moden's code,if there are more than one value then the first/last(not sure which one) returned value would be assigned[/quote]
Thanks for the reminder. I had already selected the correct values into #ADD.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply