Type of value error in ssis package

Posted on 2014-01-14
Last Modified: 2016-02-10
I have an ssis execute sql task step

It calls a stored procedure and attempts to dump the output into a user variable of type double.

It is getting a error thrown about not being able to change types mid execution if the result of the stored procedure is zero (I think).

The best way I could troubleshoot this is manually run the stored procedure.  I hard coded the store procedure to act as follows:

declare @array as table(statement float)
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.

	IF @StatementDocNo = 0
			SELECT 0 AS [Amount Due]
			-- Insert statements for procedure here
insert into @array
			SELECT DISTINCT -- select top 10 * from umcr2100
				isnull(util..UMCR2102.umAmount1,0)  AS [Discounted Amount Due]
				INNER JOIN util..UMCR2102 ON util..UMCR2100.umStatementDocNo = util..UMCR2102.umStatementDocNo
				(util..UMCR2100.umStatementDocNo = @StatementDocNo)
				umDescription1 LIKE 'Total Amount Due%'
			SELECT 0 AS [Amount Due]
		 select * from @array

Open in new window

I do not see how it is possible for the code above to throw anything not compatible with a double.  

How can I troubleshoot this/ make this work.

(The output almost always comes out to greater than zero and has a decimal).

This is written in sqlsvr 2008
Question by:UnderSeven
LVL 65

Accepted Solution

Jim Horn earned 500 total points
ID: 39779790
>SELECT 0 AS [Amount Due]
>SELECT DISTINCT ... AS [Discounted Amount Due]
>SELECT 0 AS [Amount Due]
>select * from @array

For starters, SSIS likes to create a 'contract' between it and a source of data so that it knows what schema to expect, so it can to map columns.  In your case, this means the SQL Task can't handle calling a SP where the return set is not the same schema each and every time.

You'll need to change the above four SELECTs so that it is the same exact schema.
Even better would be to only have one SELECT.

Author Closing Comment

ID: 39779840
That was it, once I normalized the output to all come from the same (explicit type) place it worked.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
A couple of weeks ago, my client requested me to implement a SSIS package that allows them to download their files from a FTP server and archives them. Microsoft SSIS is the powerful tool which allows us to proceed multiple files at same time even w…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to shrink a transaction log file down to a reasonable size.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now