import missing field from excel into a mssql 2008R2 database

Hi guys. I’m struggeling with an import from an excel file into an existing mssql 2008R2 database table. We’re missing a field in this specific table. The excel file contains a column with  the value of this missing field and one with a key.

ID:  Missing field:
01      test1
02      test2
03      test3
….
 
My question how can I update the missing field from my excel file for each row?
LVL 1
socom1985Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MakriniCommented:
How are you trying to update the table.

1. Does the table have a column for the missing field?
2. Does the table have an "ID" which corresponds with the Excel file "ID"?
3. Are you using Excel to put into SQL, or SQL to pull from Excel
4. What version of Excel
5. Are you using SSIS or openrowset, or what method?
0
planoczCommented:
It depends how you are reading the excel file.
Need more info to answer this.
0
sammySeltzerCommented:
If the Excel file has ID as shown on your example that acts as primary key and the sql server table has one as well, then my proposal might work for you.

Here is my approach.

First, dump all the contents of the excel file into a staging table.

Then compare the data on the staging table with data on the actual table based on ID from both.

Then append to the actual table any data that is on the staging table but not on the actual table.

Works for me all the time.

If you have any questions, please ask.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

ValentinoVBI ConsultantCommented:
If you need info on how to get the Excel data into a table in your database, check out the following article: http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_3248-Importing-Excel-Data-Using-Integration-Services.html
0
Marten RuneSQL Expert/Infrastructure ArchitectCommented:
A simpler aproach than SSIS is to attach the excel by using a linked server.

Regards Marten
0
ValentinoVBI ConsultantCommented:
In addition to martenrune: which can be created on the fly using the OPENROWSET function :)

But it's not always straightforward as the following article will point out: http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/A_3025-Retrieving-Data-From-Excel-Using-OPENROWSET.html
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.