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
 UPDATE using Excel/Text File?

Author  Topic 

Metcalf
Yak Posting Veteran

52 Posts

Posted - 2009-08-05 : 14:54:04
I see a lot of articles on how to update an Excel file via SQL, but is it possible to use an Excel file (or derivative thereof) to push an UPDATE query?

Reason I ask is, our purchasing department asked for a list of slow-moving parts; using their criteria I ran a query, saved the results in Excel and sent them on their way. Now they're back, carrying the same list, but they've identified ~5000 parts that need to be made 'obsolete.'

I don't want to spend the next 4 months inputting all of these part numbers into a WHERE clause verbatim. Is there any way to pass a single-column Excel file through and use each Row as a parameter to an UPDATE query?

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-08-05 : 15:07:22
What I would do:
- import wizard from ssms to import the data from excel into a table (that takes about 3 minutes)
- using this table to run my update


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

slimt_slimt
Aged Yak Warrior

746 Posts

Posted - 2009-08-05 : 15:10:08
you would still need to have 1) old version for comparison and 2) temporary data in sql table for this.

I would definitely create SSIS package which would hold on one hand replication of original excel version, compare it with new data and update rows, cells (whatever you would define) based on criteria one would define.

in your case Excel is just a medium, but in my opinion all the data should be in sql tables for faster and easier analysis, SSIS package would host as a shell for import/export data back and forth.
Go to Top of Page
   

- Advertisement -