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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Using query to update table, error, help?

Author  Topic 

sqlchiq
Posting Yak Master

133 Posts

Posted - 2008-08-22 : 11:30:23

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.



when I try to do this...


while @z < 6*@clift begin update u set u.Checkindate =(SELECT checkindate = DATEADD(DAY, n.num, d.[DATE])

FROM F_TABLE_DATE('2008-08-13', '2008-08-13') d
CROSS JOIN
(
SELECT num = 0 UNION ALL -- same DAY (Wed)
SELECT num = 3 UNION ALL -- the sat
SELECT num = 7 UNION ALL -- 1 week FROM Wed
SELECT num = 10 UNION ALL -- 1 week FROM Sat
SELECT num = 28 UNION ALL -- 4 week FROM Wed
SELECT num = 31 -- 4 week FROM Sat
) n
WHERE d.WEEKDAY_NAME = 'Wed') from #hi as u
set @z=@z+1

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-22 : 13:30:30
The error is because you're getting more than 1 record returned by select query. On what relation do you want to do update? Can you explain how you will decide what value to be updated to what record?
Go to Top of Page
   

- Advertisement -