First Run This Procedure
EXEC sp_configure ‘show advanced options’, 1;
GO
RECONFIGURE;
GO
EXEC sp_configure ‘Ad Hoc Distributed Queries’, 1;
GO
RECONFIGURE;
GO
Create Excel sheet with two column
Column 1 is : FirstName
Column 2 is : LastName
Save Excel File as contact.xls
Create On Data Table with same column name
FirstName,LastName and save table as Contact
INSERT INTO OPENROWSET (‘Microsoft.Jet.OLEDB.4.0′, ‘Excel 8.0;Database=c:\contact.xls;’,
‘SELECT * FROM [Sheet1$]‘)
SELECT TOP 5 FirstName, LastName
FROM Contact
GO
Advertisement