Example Excel Spreadsheet Import into SQL Server with TSQL

There are a number of ways to get Excel (.xls) data into SQL Server but this seems to be the most reliable (and simplest!). Particularly when trying to schedule it as a SQL Server Agent Job. It allows you to import from specific Worksheet tabs too.

INSERT INTO [dbo].[MyTable]
FROM OPENDATASOURCE('Microsoft.ACE.OLEDB.12.0','Data Source=\\$host\D$\MyData.xls; Extended Properties=Excel 8.0')...[MyWorkSheetName$]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s