INSERT data from SQL table to EXCEL

by John 5. September 2008 02:01

INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=E:\MSSQL\Reports\JobSchedules.xls;',
'SELECT JobName, ScheduleName, next_run_date FROM [Sheet1$]')

select j.name JobName, s.name ScheduleName,
 next_run_date
from msdb..sysjobs j
join msdb..sysjobschedules s
 on j.job_id = s.job_id
where j.enabled = 1
 and s.enabled = 1
ORDER BY
 j.name
GO

-- Note:
--  Requires E:\MSSQL\Reports\JobSchedules.xls to already exist with the correct columns.

Tags: ,
Categories: SQL | EXCEL

Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading