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)
 Update Statement Needed (URGENT)

Author  Topic 

ikhuram
Starting Member

28 Posts

Posted - 2004-06-01 : 03:01:52
How can update multiple columns' of a table while selecting values from another table's column. Please tell me the syntax

vganesh76
Yak Posting Veteran

64 Posts

Posted - 2004-06-01 : 04:22:21
Here is a sample code which has select values from one table and then updating the values in the base table.

update t1 set col1=b.col1,
col2 =b.col2
from t1 a,(SELECT col1,col2 from T2
WHERE T2.C1 = <CND2>) as b
where a.col1=b.col1

Enjoy working
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2004-06-01 : 04:23:42
UPDATE a
SET col1 = b.Col1, col2 = b.Col2
FROM TableA a
JOIN Tableb b
ON a.ID = b.ID
WHERE b.Amount < 100000


--***** Something like that

Duane.
Go to Top of Page

Werwolf13
Starting Member

7 Posts

Posted - 2004-06-01 : 04:31:20
it dependes on the order in which are you going to populate the destination column and to query from the source one.... write more accurate details...
Go to Top of Page
   

- Advertisement -