troubleshooting Question

Export to excel from SQL Server 2005 using OPENROWSET

Avatar of ggilal
ggilal asked on
Microsoft SQL Server
26 Comments1 Solution1402 ViewsLast Modified:
I am using :
        OPENROWSET( 'Microsoft.Jet.OLEDB.4.0',
                    'Excel 8.0;Database=D:\Test.xls',
                    'SELECT UserId, LastName,FirstName FROM [Sheet1$]')
       SELECT top 100 [User_Id], Last_Name, First_Name FROM dbo.Users
I realize that the text.xls must exist with the column names beforehand. However, I need to generate an excel file that has a different name that contains the data exported and empty the test.xls so that it will be able to be ready to receive data when a new request comes in with different parameters.
How do I do this?
Mark Wills
Topic Advisor
Join our community to see this answer!
Unlock 1 Answer and 26 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 26 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros