x

SSIS: NULL value in variable with double datatype

Hi,

Seems SSIS is having issues with NULL values passed to variables. I'm loading results from a stored procedure into a variable of type object. I then need to insert the data from the object in a table. This is done with a foreach loop. But when the sql task hits the NULL value it fails. The datatype for the NULL value is double. I've tried to catch the NULL value through the EvaluateAsExpression (ISNULL(@[User::intUptime]) ? (DT_R8) 9999 : (DT_R8) @[User::intUptime]) but with no luck. Is this a known issue in SSIS? Version used SQL Server 2008 R2

Thanks in advance,

Olivier
more ▼

asked Nov 03, 2011 at 07:21 AM in Default

Olivier Lammens gravatar image

Olivier Lammens
1 1 1 1

Can you please append the error output? Thanks.
Nov 04, 2011 at 12:27 AM Usman Butt
(comments are locked)
10|1200 characters needed characters left

3 answers: sort voted first

For tables, SSIS takes the underlying data type. For stored procs, SSIS must read the first SELECT statement to retrieve metadata for what it expects the stored proc to return. In your stored proc, use a no-op select statement to declare the meta-data for the given columns, i.e.


SELECT 
CAST(NULL AS <datatype>) AS ColumnName,
CAST(NULL AS <datatype>) AS ColumnName,
CAST(NULL AS <datatype>) AS ColumnName
...
more ▼

answered Nov 03, 2011 at 11:17 AM

the_SQL gravatar image

the_SQL
102 1 1 3

Unfortunately changing the SP is not an option. It is not managed by our team.

Olivier
Nov 04, 2011 at 12:26 AM Olivier Lammens
(comments are locked)
10|1200 characters needed characters left

You cannot use variable of type [System.Object] is not convertible to the SSIS data types.

In case you have a NULL value in it and want to handle it, you will have to use the Script Task to handle the NULL.
more ▼

answered Nov 06, 2011 at 12:17 PM

Pavel Pawlowski gravatar image

Pavel Pawlowski
22.3k 9 11 21

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

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

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:

x941

asked: Nov 03, 2011 at 07:21 AM

Seen: 1708 times

Last Updated: Nov 03, 2011 at 07:21 AM