Link to home
Start Free TrialLog in
Avatar of Suhul
Suhul

asked on

Importing Excel to SQL

How can I import an Excel work book(more than one worksheet at a time) to SQL serverusing T-sql?
Avatar of RiteshShah
RiteshShah
Flag of India image

you have quite a few options:

1.) Linked Server: http://www.sqlhub.com/2009/04/create-linked-server-with-excel-2007.html
2.) OpenRowSet: http://www.sql-server-helper.com/tips/read-import-excel-file-p01.aspx
3.) Import/Export wizard or SSIS:
ASKER CERTIFIED SOLUTION
Avatar of cyberkiwi
cyberkiwi
Flag of New Zealand 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
SOLUTION
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
Avatar of Suhul
Suhul

ASKER

that was very helpful....thank you
if you are going to use different excel files all the time, it is good to go with OPENROWSET rather than LinkedServer
Use this:


 BULK INSERT AdventureWorks.Sales.SalesOrderDetail
   FROM 'f:\orders\lineitem.xls'
   WITH
      (
         FIELDTERMINATOR =' |',
         ROWTERMINATOR =' |\n'
      )
Ritesh,
I don't know how to import all sheets without knowing their names using OPENROWSET.  Do you?
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.