March 24, 2014 at 8:05 pm
I have Table A with 20000 rows and I need to update column B values in Table A from Table B's Col C values.
How can I achieve this in a single query?
Col A and Col K are primary keys in both table A and table B
Sample:
Table A
Col A Col K Col B
A a 23
B b 45
C c 56
D d 67
E e 12
F f 87
Update Table B Column B values from Table B column C values
Table B
Col A Col K Col C
A a 213
B b 425
C c 546
D d 667
E e 172
F f 887
Thanks
March 25, 2014 at 7:33 am
You have been around here long enough to know that you need to post ddl and sample in a consumable format. If you have forgotten you can find information about how to post questions by reading the article found at the first link in my signature.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
March 25, 2014 at 7:47 am
Look up UPDATE...FROM in Books Online. There are examples which very closely match your requirement.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
March 25, 2014 at 11:42 am
Sure,will keep in mind
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply