For your sake and not simplicity, I will detail how to create a linked server here.
To link to an Excel workbook and import with no headers, I created a linked server by the following these steps:
- Open Microsoft SQL Server Management Studio Express
- Connect to your server which has the database in which you wish to create a table.
- In the Object Explorer tab, expand Server Objects.
- Right-click Linked Servers.
- Select New Linked Server.
- Under the General page, type in a name for the Linked Server.
- Select Other data source for Server Type.
- Select Microsoft Jet 4.0 OLE DB Provider.
- For Product Name, type in Excel.
- Type in the full path and filename of the Excel workbook to which you are linking in Data Source.
- In the Provider String, type Excel 8.0; HDR=NO.
- Select OK.
You should now have a linked server to your Excel workbook and it will not import the first row as headers.
In my case, my tables were separated by spacer rows. I opened the worksheet and highlighted each table. I defined names for each and used these names to import each table rather than the worksheet name.
Example:
SELECT * INTO mySQLTable FROM myExcelLinkedServer...myDefineNamedTable
Notice there are no brackets or the $ symbol. Brackets and the $ are used when importing a worksheet, not a named range.
If I had only one table and it started in cell A1, I could use the following:
SELECT * INTO mySQLTable FROM myExcelLinkedServer...[myExcelWorksheet$]

No comments:
Post a Comment