Solved

How do I update existing SQL table data from a .csv file using an update query statement containing path of the file?

Posted on 2007-11-26
3
1,152 Views
Last Modified: 2013-11-24
I am using SQL Express mgmt studio along with DTS for import/export of data....

I have an SQL table called Table1 and I want to update it with data from an Excel file called 'NewData' located at C:\NewData.csv

The file 'NewData' contains a column variable named 'IDNUMBER' and Table1 also contains this variable column called IDNUMBER. I want to update each record/row of data in Table1 with the data from the 'NewData.csv' file where the IDNUMBERS match.

All variable names/headers in NewData.csv also exist in Table1, so the mapping is direct and simple... I just need some help with the statement and integration of the path to the NewData.csv file to get this thing working...any help is really appreciated.
0
Comment
Question by:jazjef
3 Comments
 
LVL 31

Expert Comment

by:James Murrell
ID: 20353019
0
 
LVL 17

Accepted Solution

by:
pssandhu earned 500 total points
ID: 20353170
Or, you can just use the import/export wizard to load the data from the csv file into a table in your db and then link Table1 to the table that you just made and do an update.
0
 
LVL 4

Author Comment

by:jazjef
ID: 20354938
Good ideas guys. I had a hunch that the 'import to a new table and then update' might work.... This appears to be the most feasible method at the moment. The UPDATE option gives me flexibility and its really easy via DTS to get the data into a new temp table.....

I had no knowledge of the 'bulk insert' .... that's an interesting idea. Does 'bulk insert' simply insert the whole file or can I specify that the insert occur where the IDNUMBER matches etc? The link doesn't really say.....
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
This collection of functions covers all the normal rounding methods of just about any numeric value.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question