View previous topic :: View next topic |
Author |
Message |
Piscesian Beginner
Joined: 17 Dec 2004 Posts: 14 Topics: 8 Location: Monrovia,California
|
Posted: Fri Jun 01, 2007 6:31 pm Post subject: Update query |
|
|
Hi,
I need to update a particular DB2 table based on fixed set of values that I
have in an excel spreadsheet.
Code: |
Table A Table B
SANUM = 1545 SANUM = 1545
BG_TYP_CD = 01 SC_CD = 139
|
Values in excel sheet
Code: |
SC_CD BG_TYP_CD
139 16
151 15
190 11
--- --
--- --
|
I need to update BG_TYP_CD in Table A with value of 16
There are approx 1000 records that need to be updated.How do I achieve
this through an SQL query? |
|
Back to top |
|
|
William Thompson Beginner
Joined: 15 May 2007 Posts: 5 Topics: 0
|
Posted: Fri Jun 01, 2007 6:50 pm Post subject: |
|
|
Got a lot a data manipulation in front of you....
Define the input format you need and then figure out how to produce that format from Excel....
Good luck.
ps, it can be done, I have (almost the same thing) done it, but I've slept since then....grin..... |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Fri Jun 01, 2007 6:51 pm Post subject: |
|
|
Piscesian,
Try this
Code: |
UPDATE Table_A
SET BG_TYP_CD = 16
WHERE SANUM = (SELECT SANUM
FROM Table_B
WHERE SC_CD = 139);
|
If you want to do it 1000 rows then upload the excel to the mainframe and run it thru a utility to generate the sql statement shown above
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
Piscesian Beginner
Joined: 17 Dec 2004 Posts: 14 Topics: 8 Location: Monrovia,California
|
Posted: Sat Jun 02, 2007 5:15 pm Post subject: |
|
|
Thanks William,Kolusu for your inputs.... |
|
Back to top |
|
|
sendhil Beginner
Joined: 06 Sep 2006 Posts: 17 Topics: 6
|
Posted: Sat Jun 02, 2007 8:45 pm Post subject: |
|
|
A formula in excel might do the trick? You can generate the sql in excel itself. |
|
Back to top |
|
|
|
|