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 2008 Forums
 Transact-SQL (2008)
 Change column value query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

murd
Starting Member

23 Posts

Posted - 12/03/2012 :  15:08:00  Show Profile  Reply with Quote
I need to update/change values to a column w/ a specific range
from a different table.


example


table1 table 2
CID DID
1 100
2 200
3 300
4 400
5 500
6 600

I want to update CID from <=4 to the corresponding DID

Results
CID
100
200
300
400

hope I explained this right...thx

shilpash
Posting Yak Master

101 Posts

Posted - 12/03/2012 :  16:46:08  Show Profile  Reply with Quote
so do you want your final output look like these--

CID DID
100 100
200 200
300 300
400 400
5 500
6 600
Go to Top of Page

shilpash
Posting Yak Master

101 Posts

Posted - 12/03/2012 :  16:52:44  Show Profile  Reply with Quote
If so,use this---
UPDATE tablename
SET cid = did
FROM tablename
WHERE cid <= 4
Go to Top of Page

murd
Starting Member

23 Posts

Posted - 12/04/2012 :  00:07:57  Show Profile  Reply with Quote
yes!! thanks ill try this
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.05 seconds. Powered By: Snitz Forums 2000