x

SSIS, check excel destination if excel excel file exists

SSIS: Hi, DO we have anything to do like (if exists) like checking the excel file in the folder, because the SSIS package should run every attempt

if I use drop and create(Execute sql task) for the first attempt it gonna fail as I don't have existing Excel file on my drive. Please let me know I struck thr :(

My requirement:

SQL server data should export to excel .

If Excel file did not exist, then Package should create a file, if it exists then the package should delete the file and should recreate

more ▼

asked Apr 11 at 08:36 PM in Default

avatar image

jangi
11 1 1 4

(comments are locked)
10|1200 characters needed characters left

3 answers: sort voted first

you need to write script task which take parameter 0 if file not exists and 1 when this file exists, after that you have to set up in precedense constraint editor, if value from script task is equal to 1 that everything go further, if this value is equal to 0 then package is not going further

some scripts below for checking if file exists, for rest that you need you have to take a look in google

https://stackoverflow.com/questions/17568554/ssis-script-task-to-check-if-file-exists-in-folder-or-not/17573837

more ▼

answered Apr 12 at 10:33 AM

avatar image

Lukasz8519
136 2 2

I can't provide the path in the package as it runs in different environments.

Could you please help me with some dynamic script for it like " if exist and if not exist"

Apr 12 at 12:47 PM jangi
(comments are locked)
10|1200 characters needed characters left

so, you have to build path using variables and try to concatenate them to valid file path

https://social.msdn.microsoft.com/Forums/en-US/b162adc5-8809-4eba-be22-bc75f549917e/dynamic-file-path-in-ssis?forum=sqlintegrationservices

you can add parameters, and after that when you run in different envs you can run package with proper parameter for that envs in google you can find many examples, good exercise for You to improve Your skills

more ▼

answered Apr 12 at 12:53 PM

avatar image

Lukasz8519
136 2 2

I am at learning state in SSIS, I will try to achieve it.

I thought thr will be some script like we use in TSQL (if exists and if not exists) as we are using sql statements in "execute sql task".

SO I thought I can do something like that in simple.

Apr 12 at 01:08 PM jangi
(comments are locked)
10|1200 characters needed characters left

no, you can't write simple t-sql proc, but this case is not difficult, doing that step by step you learn a lot. don't worry everything will be fine, remember step by step

more ▼

answered Apr 13 at 06:22 AM

avatar image

Lukasz8519
136 2 2

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x1245

asked: Apr 11 at 08:36 PM

Seen: 25 times

Last Updated: Apr 13 at 06:22 AM

Copyright 2018 Redgate Software. Privacy Policy