Import and Export data from SQL Server 2005 to XL Sheet
Posted
by
SAMIR BHOGAYTA
on Samir ASP.NET with C# Technology
See other posts from Samir ASP.NET with C# Technology
or by SAMIR BHOGAYTA
Published on 2010-07-05T19:36:00.000-07:00
Indexed on
2010/12/06
17:00 UTC
Read the original article
Hit count: 505
Import and Export data fr
Expample linked server creation:
Before you executing the below command the excel sheet should be created in the specified path and it should contain the name of the columns.
EXEC sp_addlinkedserver 'ExcelSource2',
'Jet 4.0',
'Microsoft.Jet.OLEDB.4.0',
'C:\Srinivas\Vdirectory\Testing\Marks.xls',
NULL,
'Excel 5.0'
Once you executed above query it will crate linked server in SQL Server 2005.
The following are the Query from sending the data from Excel sheet to SQL Server 2005.
INSERT INTO emp SELECT * from OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\text.xls','SELECT * FROM [sheet1$]')
The following query is for sending the data from SQL Server 2005 to Excel Sheet.
insert into OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=c:\text.xls;',
'SELECT * FROM [sheet1$]') select * from emp
© Samir ASP.NET with C# Technology or respective owner