Do The Following Step to Export Data from Sql Server to Excel
1)Create an Excel Datasheet save it with name testingExcel in D:/testingExcel.xls2)Save Type of excel sheet should be Excel 97-2003 Worbook.
3)Then enable the 'ad hoc distributed queries' in surface area configuration using sp_configure
EXEC sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
EXEC sp_configure 'Ad Hoc Distributed Queries', 1;
GO
RECONFIGURE;
GO
4)Then with the help of openrowset function you can insert the data of sql server table to worksheet. Yet not finished you have to create column in excel sheet with the name StreamName and IsActive
INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=D:\testingExcel.xls;','SELECT StreamName,IsActive FROM [Sheet1$]') select StreamName,IsActive from StreamMaster
go
5)Be sure you have closed your excel sheet befor executing the above query.
6) Thats all you need to do to export data to excel sheet.
Post Reference: Vikram Aristocratic Elfin Share
No comments:
Post a Comment