Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have an Excel file in C:\testing.xlsx. I am exporting data from my database table to Excel using [OPENROWSET (Transact-SQL)]1 method. Now I want to

  1. clear or delete all rows in my Excel file by executing some query in SQL Server
  2. delete or create new Excel file in specified path (ie C:\) from SQL Server

Can I do this? If, please suggest me how to do that?

share|improve this question

3 Answers 3

I have got one very useful link which i have not tried. But, its a great stuff by author...

share|improve this answer

Not sure about modifying the excel file (have you tried deleting rows?). As far as modifying files on the filesystem... if you enable xp_cmdshell you can run any command line commands on the system (like copy or delete).

share|improve this answer

You might want to use simple SSIS package to do that. Just create a new project in Business Intelligence Development Studio (VS2008) - it goes along with yur SQL Server installation and very easy to start.

share|improve this answer
    
I agree with Vlad. SSIS was meant to be used for these type of ETL activities. –  StanleyJohns Jan 9 '12 at 18:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.