Tuesday, March 27, 2012

Delete an excel worksheet only if it exists, in a dts package

Hi :

1. I import data into sqlserver, from an excel file, from a worksheet
within it, named 'input_data'
2. then i scrub the data in sqlserver
3. then i export some data into the same excelfile but into another
worksheet named 'output_data'

I have got it working and this is how i am doing it right now. I am
having a problem in the few steps identified below :

1. I delete the worksheet 'output_data' using an execsql task
DROP TABLE `output_data'

2. Then i have another execsql task to create it
CREATE TABLE `output_data`

3. Then i have datapump task to put data into worksheet.

The work fine, but i am running into a problem, when the output_data
worksheet doesnt exist.
So i need to write a query telling
IF `output_data` doesnt exist, then DROP IT

How do i do this
I am open to doing this in ActiveX Script(vbscript) and ExecSQL task

Also i do not have excel dll or runtime in my dbserver.

Please let me know
thanks
RSapologize for typo
I do have a problem, when 'output_data' worksheet does exist
and hence need a query telling,

if output_data worksheet exists, then drop it

thank you
RS

No comments:

Post a Comment