Linked Server table from Excel

If I don't have a range in my Excel spreadsheet I can't select that table (range) once I'm linked to the sql.  How can I name the range during the process of linking to the file from sql utilizing sp_addlinkedserver?
wordtoolAsked:
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.

wordtoolAuthor Commented:
Please note that I am actually linking to a .csv file.
0
wordtoolAuthor Commented:
I'm using the following:

EXEC master..sp_addlinkedserver 'Excel',
   'Jet 4.0',
   'Microsoft.Jet.OLEDB.4.0',
      '\\myserver\shared\Data_In\1371.xls',
   NULL,
   'Excel 5.0'
GO

Is there a different syntax I should be using for .csv files?
0
Brendt HessSenior DBACommented:
The last parameter (for a CSV file) is not Excel 5.0.  It should be 'Text', from what I know of it.
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
BillAn1Commented:
If you've saved the excel as a csv file, then there is no such thing as named ranges etc. a csv is simply a text file.

If you have saved it as an xls file, as you indicate in your linked server connection details, then, if you want to use named ranges, you need to create these within the Excel spreadsheet. This is not something that can be done easily from within SQLServer (I say easily because, ultimatley anything can be done, with extended stored procs, and command shell, you can virtually anything)

However, you don't necessarily need to use named ranges - you can use sheet references, as in

SELECT * FROM EXCEL...SHEET1$
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.