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 2000 Forums
 Transact-SQL (2000)
 Updating a table based on another table

Author  Topic 

uniquegodwin
Starting Member

12 Posts

Posted - 2006-02-08 : 03:10:47
Please help me with this...Here is the query I tried and it says subquery cannot give more than 1 value.So what do I do for it? How do i shape this query to work?
Thanks a million
Following is the query...

UPDATE tblLeadActivities
SET f_activityName =
(SELECT f_activityName
FROM tblStandardActivities)
WHERE (f_leadId = '0602HOUS3')

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-02-08 : 03:13:42
This is becuase this (SELECT f_activityName FROM tblStandardActivities) returns more than 1 value.
Use this syntax.
UPDATE U
set U.col1 = T.col1
FROM table1 U inner join table2 T
ON U.pk = T.pk


----------------------------------
'KH'


Go to Top of Page

uniquegodwin
Starting Member

12 Posts

Posted - 2006-02-08 : 03:27:24
Hi,
Im new to this database thing...Im not sure how to substitute in that template you've given me..
...please help me with that too if possible...Please dont mind..Im sorry for asking so much.

Thanks
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-08 : 03:33:17

UPDATE L
SET f_activityName =S.f_activityName
from tblLeadActivities L inner join tblStandardActivities S
on L.f_activityName=S.f_activityName WHERE S.f_leadId = '0602HOUS3'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -