Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Simple SQL to update specific columns
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Ask SQLTeam Question

0 Posts

Posted - 08/31/2005 :  07:36:52  Show Profile  Visit AskSQLTeam's Homepage  Reply with Quote
Kairn writes "I have created a table and imported data from another table to it. I need to update the existing data with values from another import but only need specific columns and am assuming a stored procedure is the way to go...IF I create a source table as well as destination(?). I have to compare the value in 6 columns to find the matching record in the destination, then update 5 of the other columns where source=dest. Finally, I need to sum, by row, the value in 3 of the columns and update another column to reflect it. All rows are unique in the destination. The source is a duplicate of them. Basically, the rows are identical aside from the values in the columns I want transferred. The rows must remain unique. I am a newbie and have no idea how to do this. Would you please submit a basic outline and I can fill in the rest?

Thank-you very much for your time and expertise,

SQL Slashing Gunting Master

3246 Posts

Posted - 08/31/2005 :  12:15:35  Show Profile  Visit AjarnMark's Homepage  Reply with Quote
Okay, here's a template:
  t1.Field1 = t2.Field1,
  t1.Field2 = t2.Field2,
  t1.Field3 = (t2.Field3 + t2.Field4 + t2.Field5)
  DestTable t1
  JOIN SourceTable t2 on t1.PKField = t2.PKField
  t1.Field9 = t2.Field9


Edited by - AjarnMark on 08/31/2005 12:16:19
Go to Top of Page
  Previous Topic Topic Next 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.02 seconds. Powered By: Snitz Forums 2000