1

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?

3 Answers 3

1

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

1

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).

1

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.

1
  • I agree with Vlad. SSIS was meant to be used for these type of ETL activities. Jan 9, 2012 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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