Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 Export Data to Excel

Author  Topic 

durgapras
Starting Member

15 Posts

Posted - 2008-02-23 : 23:42:33
Hi,
I am currently running the following query to export Data from a table to a ExcelSheet(test.xls)

INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\test.xls;',
'SELECT * FROM [Sheet1$]') select * from SYSCUST_AUDIT



Everything is working fine.NP's so far.
The thing what I am really looking for is,Is there a way where I can write a query and it should dynamically create a Excel sheet and export the data from the table.

Now I have manually created test.xls.
What I am looking for is ,Write some query which dynamically creates
test_'Date'.xls and export the data from the table.So after 5 days,My c:folder should have following files

test_'date1'.xls
test_'date2'.xls
test_'date3'.xls
test_'date4'.xls
test_'date5'.xls

Thanks in advance

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2008-02-24 : 00:38:34
There are ways using VB Script that can do it....not sure if it can be done using the openrowset method...

There are tons of ways to dynamically create, name and manipulate excel using the excel object in VB or C# scripting. It would be easier still to have Excel do all the work using MS Query and VBA within the excel file--excel can even be set up to open automatically, run the code, and close.



Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page
   

- Advertisement -