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.
Author |
Topic |
Patyk
Yak Posting Veteran
74 Posts |
Posted - 2014-10-17 : 16:07:11
|
I need to update this old table with new data105 FIELD 2015 15190 17516 13231 8607 6582105 STORE 2015 35855 30647 29781 27642 24784105 ULT 2015 120291 23015 26995 33918 22100columns custId Type Year month1 month2 month3 month4 month5My new table looks the same.Primary Key CustId Type YearThanks |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-10-17 : 16:10:38
|
I'm unclear what you are asking. Show us sample data for the old table and what it should look like after the update.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
Patyk
Yak Posting Veteran
74 Posts |
Posted - 2014-10-17 : 16:18:45
|
I need to update the following table (here is the sample) with new Monthly Budgets are are in another table with New Data Columns in both tables are the same. Primary Key CustId Type YearcustId Type Year month1 month2 month3 month4 month5105 FIELD 2015 15190 17516 13231 8607 6582105 STORE 2015 35855 30647 29781 27642 24784105 ULT 2015 120291 23015 26995 33918 2210 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-10-17 : 16:21:32
|
You already provided that data. It didn't make it clear. Please read this article for how to post a clear question with sample data so that we can help you: http://www.sqlservercentral.com/articles/Best+Practices/61537/Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
Patyk
Yak Posting Veteran
74 Posts |
Posted - 2014-10-17 : 16:36:58
|
Sorry I just need to update the data above with new values from my new table105 FIELD 2015 15190 1000 13231 5894 6582105 STORE 2015 5000 30647 29781 27642 5268105 ULT 2015 120291 23015 200 33918 3654I need to find the matching records where CustId, StoreId, and Year are the same and update values for Month1, Month2, Month3,Month4, and Month5My Master Budget Table needs to be updated with new values . |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-10-17 : 16:47:43
|
I'll provide an example.UPDATE t1SET col5 = t2.col5, col6 = t2.col6FROM table1 t1JOIN table2 t2 ON t1.col1 = t2.col1Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
|
|
|