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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing Excel to SQL - Trouble with worksheets, maybe???

Status
Not open for further replies.

netcashin

Programmer
Nov 13, 2000
159
0
0
US
I am trying to copy a table in Excel to SQL. I am using a Bulk Insert in a stored procedure. With the bulk insert I just need to give the Excel file path and name. There is two worksheets in the Excel spreadsheet and I believe that the problem is that it is trying to copy the data from the wrong worksheet and is giving me a wrong column type error.

Is there a way to reference a specific worksheet in a Excel file?

Or does anyone know of another way to copy a Excel table to SQL programtically?

I am also first to admit that I don't really know much about Excel, but I am strong with database basics.

Thanks
 
Try using the bulk insert on a named range. I dont know the
Bulk Insert SQL process too well but in Excel select all cells on one sheet that have the data that you require. Next go to the Name Box (directly above the spreadsheet area - to the left of the = symbol) and type in a name <NO SPACES> eg sheet1data. and then press enter. Only pressing enter will attribute the name to the range. Go to the next sheet and repeat the process with a different name. At any time in the sheet you can go to the name range box and select the name from the list and you will be taken ,as if by magic, to that range of cells.
I know for sure that the Access import routine allows you to import data that has been named like this so hopefully SQL will too.
HTH
Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top