SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 update on different in value
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

gangadhara.ms
Constraint Violating Yak Guru

India
497 Posts

Posted - 04/02/2012 :  00:54:23  Show Profile  Visit gangadhara.ms's Homepage  Reply with Quote
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
Constraint Violating Yak Guru

India
497 Posts

Posted - 04/02/2012 :  00:58:41  Show Profile  Visit gangadhara.ms's Homepage  Reply with Quote
Note: Need to update only records which are having a different in value.

Go to Top of Page

Srinika
Flowing Fount of Yak Knowledge

Sri Lanka
1378 Posts

Posted - 04/02/2012 :  11:34:52  Show Profile  Reply with Quote
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

Sweden
29138 Posts

Posted - 04/02/2012 :  12:36:20  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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"

Edited by - SwePeso on 04/02/2012 12:36:39
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000