Search This Blog

Tuesday, May 26, 2009

Exporting to Excel from SQL Server

--

INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\Book.xls;',
'SELECT Name, Date FROM [Sheet1$]')
SELECT [Name], GETDATE() FROM msdb.dbo.sysjobs
GO


To use OPENROWSET command

1. The Excel file must exist. You can use a file as template.
2. Enable OPENROWSET command from SQL Server 2005 Surface Area Configuration
utility.
Post a Comment

Popular Posts