Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing an Excel Column into SQL Server

Status
Not open for further replies.

Mayoor

Programmer
Jan 16, 2004
198
GB
Hi I have corrupted the data in a colum in my SQL Server Table. I have the original data in an excel spreadsheet which i wish to use to append the data in the SQL Server db.

However I wish to only copy a particular column from excel and use it to overwrite a specific column in SQL Server. Both excel and sql server are sorted in the right order so all I need is a straight overwrite.

Im guessing I use DTS, but which options do I need. I can seem to see any option which allows me to do this.
 
My guess would be to import the entire spreadsheet into a new table in SQL Server. Then you can run an UPDATE query against the original SQL table with the data from the new table.
Is this a good idea?
 
>> Both excel and sql server are sorted in the right order
excel might be but the data in an sql server table can't be accessed in the stored order.

I would create update statments from the excel spreadsheet and copy them to query analyser.
Assuming you have an ID field

Put something like this in the top row
="update tbl set fld = " & B1 & " where id = " & A1
copy it down
then copy the result into query analyser and you should have a series of update statements that will correct your data.

======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
I have a similar situation, but I am unfamiliar with the excel part. Could you be more detailed in your explanation?



Thanks s-)
Kim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top