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)
 update on different in value

Author  Topic 

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2012-04-02 : 00:54:23
Hi All,

I have 2 tables Tab1 and Tab2

I need to update Tab1 columnA from Tab2 columnA for each row in the first table.

Pls help

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2012-04-02 : 00:58:41
Note: Need to update only records which are having a different in value.

Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2012-04-02 : 11:34:52
Please provide some sample data.
Also tell, how the 2 tables are related

Srinika
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-04-02 : 12:36:20
UPDATE t1
SET t1.Col2 = t2.ColX
FROM dbo.Table1 AS t2
INNER JOIN dbo.Table2 AS t2 ON t2.ColGreen = t1.ColWarm
WHERE t1.Col2 <> t2.ColX


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -