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
 General SQL Server Forums
 New to SQL Server Programming
 I hate joins
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

WJHamel
Aged Yak Warrior

USA
614 Posts

Posted - 04/13/2012 :  11:17:10  Show Profile  Reply with Quote
alot.

I have two tables: Civil.dbo.receipts and civil.dbo.gcsoreceipts. I need to update the values in the CLERK column in civil.dbo.receipts with the value in the gcsoreceipts table. The identifying column which both tables have in common is the receiptno field. I'm assuming it's a join that will bring peace to my world. Please help me understand how that would look.

thanks

james

Lamprey
Flowing Fount of Yak Knowledge

3832 Posts

Posted - 04/13/2012 :  11:24:32  Show Profile  Reply with Quote
It should be fairly easy, but please help us to help you. Pease post DDL, DML and expected output. The following links will help you prepare that for us in a consumable format.

http://www.sqlservercentral.com/articles/Best+Practices/61537/
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

sunitabeck
Flowing Fount of Yak Knowledge

5152 Posts

Posted - 04/13/2012 :  11:25:29  Show Profile  Reply with Quote
Something like this? Hard to say without seeing the table DDLs. In any case, uncomment the two lines I have commented out and run the select part to see what is going to be updated before you use it if you choose to use it.
UPDATE r SET
	r.CLERK = g.CLERK
--SELECT
--	r.CLERK,g.CLERK
FROM
	Civil.dbo.receipts r
	INNER JOIN  civil.dbo.gcsoreceipts g ON
		g.receiptno = r.receiptno;
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47173 Posts

Posted - 04/13/2012 :  11:30:13  Show Profile  Reply with Quote
first question is how tables Civil.dbo.receipts and civil.dbo.gcsoreceipts are related. is relation 1:1 or 1:n. If latter how do you want update to happen? is it somekind of rollup (aggregation) or do you want one specific occurance value to be updated for each receiptno ?

As suggested by others, posting some data should give us more idea

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

WJHamel
Aged Yak Warrior

USA
614 Posts

Posted - 04/13/2012 :  11:37:49  Show Profile  Reply with Quote
looking more closely at this now. may be more than i thought it to be. will be back. thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47173 Posts

Posted - 04/13/2012 :  11:43:47  Show Profile  Reply with Quote
no problem. take your time

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

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