Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Type of value error in ssis package

Posted on 2014-01-14
2
Medium Priority
?
344 Views
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.
	SET NOCOUNT ON;

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

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
0
Comment
Question by:UnderSeven
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 2000 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.
0
 

Author Closing Comment

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

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

721 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