I want to export the result of a stored procedure execution to a excel worksheet,I want to set this up as a Job which will generate the result and store it in a excel worksheet.Is this possible I have googled it but not found any convincing workable solutions
            Asked
            
        
        
            Active
            
        
            Viewed 419 times
        
    0
            
            
        - 
                    Scheduled SSIS package, see http://stackoverflow.com/a/87772/246342 – Alex K. Jun 24 '14 at 11:39
 
1 Answers
1
            You can use INSERT INTO OPENROWSET, for example:
INSERT INTO OPENROWSET ('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=D:\Output.xls;', 'EXEC   [dbo].[spName] ''param''') EXEC [dbo].[spName] 'param'
You should enable Ad Hoc Distributed Queries before:
EXEC sp_configure 'show advanced options', 1
RECONFIGURE
GO
EXEC sp_configure 'ad hoc distributed queries', 1
RECONFIGURE
GO
        Saber
        
- 2,440
 - 1
 - 25
 - 40