Quantcast
Viewing all articles
Browse latest Browse all 24688

Get SSIS to report failure when running a sqlcmd task

Hi,

We have an SIS package with a single 'Execute Process Task' that executes sqlcmd.exe as follows

-S <sqlInstance> -d <dbname> -Q <StoredProc> -o <outputFileName>

The output is a csv file containing the output of 30 queries each headed with the query name
and footed by a blank row.

The Stored procedure that creates this contains the 30 queries, each selects a hard coded string as
the query title followed by a subsequent select of columns from different tables. The columns are aliased
with a name followed by commas in single quotes to give the comma separators along the lines of -

<columnName> AS <alias>,', ',', 

The net result is a single csv file of the 30 queries, opened in Excel, that gives the 30 different width
tables that the 30 queries generate.

This works fine but, on the odd occasion one of the queries encounters an invalid character - a '?' in a column
that it is attempting to cast as an int. In this instance, the csv file gets created and will contain all output
up to the error then the error message itself.

The problem is that the SSIS package completes and always reports DT_SER_SUCCESS (0) (probably because the file is created).

I cannot fathom a way to get the SSIS to report DT_SER_FAILURE (1) as is required on these occasions

Does anyone have any idea how this can be done? 

Thanks


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>