Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - SQL Server - Import from Excel
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

SQL Server - Import from Excel

 Post Reply Post Reply
Author
Gary View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 March 2002
Location: United Kingdom
Status: Offline
Points: 326
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gary Quote  Post ReplyReply Direct Link To This Post Topic: SQL Server - Import from Excel
    Posted: 12 May 2003 at 5:23am

Is there any way that I can get SQL Server to import data from the first sheet within an Excel Spreadsheet.....

I have a DTS package which points to a specifically named sheet (eg Sheet1 as default), but what if Sheet1 doesn't exist (ie named as something else such as mySheet)??? Is there a way to get the DTS to import the first sheet, regardless of its name ???

Thx

Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post Posted: 12 May 2003 at 8:54pm

Well you can write the DTS code in VBScript in which case you may be able to access a collection object from within Excel.

Something like:

mySpreadsheet.Sheets(1)

Not sure though..  Try searching google  - might come up with some options..

Cheers,
Andrew

There have been many, many posts made throughout the world...
This was one of them.
Back to Top
Flamewave View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 June 2002
Location: United States
Status: Offline
Points: 376
Post Options Post Options   Thanks (0) Thanks(0)   Quote Flamewave Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2003 at 10:39pm
You can also use the Enterprise manager to import data from any excel worksheet. Open up the server in Enterprise manager, right-click on it,  and goto all-tasks -> import data. When it asks for the Data Source, choose Microsoft Excel 97-200 (or the appropiate version) from the list, and then browse to the excel file on your computer. Then select where you want the data to goto on the next screen. Eventually you will come to a screen where it will ask you what "tables," or sheets you want to import, select the ones you want, and continue on with the process. Its fairly simple and straight forward. Hope that helps you out.
- Flamewave

They say the grass is greener on the other side, but if you really think about it, the grass is greener on both sides.
Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2003 at 11:07pm

I think Gary knows this.

He wants to know how he can refer the the worksheet within a spreadhseet by its ordinal (number) rather than its name.

Cheers,
Andrew

There have been many, many posts made throughout the world...
This was one of them.
Back to Top
Gary View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 March 2002
Location: United Kingdom
Status: Offline
Points: 326
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gary Quote  Post ReplyReply Direct Link To This Post Posted: 20 May 2003 at 2:36am

Andrew is right - I am fully aware and capable of design dts packages to suit my needs.

However, if you want to import from Excel, you have to choose which sheet you want to import from (pretty much in the same way that you choose a table from a db). The problem is that the Excel spreadsheet may not contain 'Sheet1' and therefore this cause the DTS to fail is I implicity define the named sheet.

So, the solution that I am after is a way of importing from the first sheet, regardless of its actual name. I want it to work along the lines of what you can do with a recordset. In other words, if I have a recordset (rs) then I can reference the contained columns by name or by their sequence (0,1,2,3,etc - rs(1)).

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.