SQLTeam.com | Weblogs | Forums

Inserting data from microsoft excel to sql server


#1

Hi I have bulk of data in excel sheet i should enter that data into sql database the problem is in sql database i have data before only before inserting the data is should check and enter and the excel sheet data should go for three different tables how to that please help me


#2

Create a working table to import the data to, then split the data to the three tables as appropriate.


#3

You can also use BULK INSERT OR OPENROWSET, something like this:

USE YourDatabase
Go

sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
sp_configure 'Ad Hoc Distributed Queries', 1
GO
RECONFIGURE
SELECT * INTO tblImport 
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
                         'Excel 12.0 Xml;HDR=YES;Database=C:\testdata.xlsx;',
                         'SELECT * FROM [Sheet1$]')