Home Products Support Sales Corporate
Products
Performance Monitor
Database Compare
Database Manager
Job Scheduler






Home > Articles > SQL Server Development & T-SQL > OPENROWSET: Import data into SQL Server tables

OPENROWSET: Import data into SQL Server tables



The OPENROWSET feature in SQL Server and MSDE provides a fast and easy way to open an OLE DB compatible data source, such as an Excel sheet, directly from your SQL script. Coupled with the "SELECT * INTO" command, the OPENROWSET feature can import data from an Excel sheet into a table in SQL Server or MSDE.

Run the following command from the SQL window in Teratrax Database Manager. This example uses the OLE DB Provider for Microsoft Excel to access sheet1 in the Excel file c:\book1.xls.

 

SELECT *
INTO db1.dbo.table1
FROM OPENROWSET('MSDASQL',
    'Driver={Microsoft Excel Driver (*.xls)};DBQ=c:\book1.xls',
    'SELECT * FROM [sheet1$]')

 

table1 will be created in the db1 database. The content of this table will be imported from the sheet1 worksheet in your c:\book1.xls Excel file.



Tools

Troubleshoot SQL Server Performance


Compare and Sync SQL Server Databases


Import & Export SQL Server Data


Schedule SQL Server Express Backups







Articles

Advantages of SQL Server 64-bit


Understanding SQL Server Blocking & Deadlocks


SQL Server Memory Internals

Privacy Statement License Agreement Articles Site Map         Copyright © 2002-2010 Teratrax Inc. All rights reserved.