Thursday, November 1, 2012

How to import data from Excel to SQL Server


How to import data from Excel to SQL Server


Introduction


In this article you will see how to use the SQL Server import an MS Excel file on your computer to a database on your SQL Server.


Open The Sql Query window select the database and Type

create database samp

go
sp_configure 'show advanced options',1 
reconfigure with override 
go 
sp_configure 'Ad Hoc Distributed Queries',1 
reconfigure with override 
go
SELECT * into temptable
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
                'Excel 8.0;DATABASE=C:\Users\RAJU\Desktop\pincodes.xls;IMEX=1',
                'SELECT * FROM [Sheet1$]')

select * from temptable




0 comments:

Post a Comment