Counter of Festivals

Ashok Blog for SQL Learners and Beginners and Experts

Tuesday, 22 October 2013

Date import from excel sheet to SQL Server

                                    Insert Excel sheet values to SQL Server 2005


First of all Turn on the adhoc Distributed Quries in your SQL Server using below statement

sp_configure 'Ad Hoc Distributed Queries',1

reconfigure

SELECT * 
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
                'Excel 8.0;Database=D:\SQL\JobDetails.xls',
                'SELECT * FROM [Sheet1$]')


Now u can view the excel data in your SQL SERVER DB.

If u want to insert values as table use as same below

SELECT * into jobdetails
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
                'Excel 8.0;Database=D:\SQL\JobDetails.xls',
                'SELECT * FROM [Sheet1$]')

select * from jobdetails