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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL newbie: Conditional Mass Update question

Author  Topic 

skeebop
Starting Member

1 Post

Posted - 2010-11-29 : 10:32:32
Hi, total sql neophyte here.

I have a table (AllTrans) where I need to update one column, AcctID, based on the value in another column, TransID. There are 4500 rows that need updating, and each TransID can have one of 47 AcctIDs.

I have an Excel spreadsheet mapping which TransIDs should have which AcctIDs, but I don't have the faintest inkling what the best way to get that info into the sql table is.

I figure I could cobble together some type of update-select-case query with 4500 cases, but I'm sure that's not the best way...

Any help is greatly appreciated.

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-11-29 : 11:41:31
What version of sql you are using ?

Can you post the script of all the tables involved in processing along with some sample data.
Go to Top of Page

TimSman
Posting Yak Master

127 Posts

Posted - 2010-11-29 : 11:45:55
You're going to need more than just a mapping between TransID and AcctID in this case. You will need a way to identify the appropriate AcctID, and what it should be updated to (so a way to find the "old" ID, and then map it to the "new" ID).
Go to Top of Page
   

- Advertisement -