Link to home
Start Free TrialLog in
Avatar of ict-torquilclark
ict-torquilclark

asked on

IMport from Excel into SQL

I am trying to import a spreadsheet into a SQL Table.

I have been trying to do this for 3 days no with no luck. Its beginning to get really frustrating.

By the looks of it the best way is to use linked Servers. I will attach how I have setup the linked server as a picture).

I then use the attached code to do the import and recieve the following error:

" Msg 208, Level 16, State 1, Line 3
Invalid object name 'EXCELLINK'. "

I have run " select * from sys.servers " and it returns that there is a Linked Server called EXCELLINK.

Can anybody suggest anything?

SELECT * INTO sanctionslist FROM EXCELLINK[sanctionslist$]

Open in new window

untitled.JPG
Avatar of mfreuden
mfreuden

SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel
8.0;DataSource=C:\purchases.xls','SELECT * FROM [sheet1$]')

This is for excel 2003 and a 32 bit SQL Server.


Avatar of ict-torquilclark

ASKER

I have run the attached code and have received the following error

"
Msg 102, Level 15, State 1, Line 4
Incorrect syntax near 'SELECT * FROM [sanctionlist$]'.
"

The worksheet is definetly called sanctionlist
SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel
8.0;DataSource=C:\SANCTIONSLIST.xls','SELECT * FROM [sanctionlist$]'

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of RiteshShah
RiteshShah
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial