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. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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


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.