Solved

SSIS. Execute SQL Task Parameter Mapping

Posted on 2014-10-23
3
263 Views
Last Modified: 2016-02-11
Hi there,

I have this SQL query in the SQL Execute Task Editor:

INSERT INTO [aging].[dbo].[ag_ageddebtor]
SELECT * FROM [aging].[dbo].[ag_ageddebtor_staging]
WHERE [Co Code] IN (?)

Open in new window

.

In the parameter mapping I have the following user defined variable: 'User::CompanyCode' that has the following values ('8560',4956','5863','6245') and it is a string data type.

I have set the parameter mapping as follows for this variable:
1. Direction: Input
2. Data Type: VARCHAR
3. Parameter Name: 0
4. Parameter Size: -1

The SQL does not execute as expected i.e. returns 0 records.

However, if I put query in the SQL Execute task it works:

INSERT INTO [aging].[dbo].[ag_ageddebtor]
SELECT * FROM [aging].[dbo].[ag_ageddebtor_staging]
WHERE [Co Code] IN ('8560',4956','5863','6245')

Open in new window

.

What I'm I doing wrong?

Thanks

OS
0
Comment
Question by:onesegun
  • 2
3 Comments
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40399852
You said:

In the parameter mapping I have the following user defined variable: 'User::CompanyCode' that has the following values ('8560',4956','5863','6245') and it is a string data type.

Does User::CompanyCode have ('8560',4956','5863','6245') or '8560',4956','5863','6245' - i.e. are the brackets included?
0
 

Author Comment

by:onesegun
ID: 40399882
No the brackets are not included.....
0
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40399905
I think it's because SSIS is including an extra pair of quotes.

For example, you had

SELECT * FROM Production.Product WHERE ProductName like ?

and you had a parameter of Hello, then it would translate it as:

SELECT * FROM Production.Product WHERE ProductName like 'Hello'

Note that the above has gain extra quote marks.

Therefore, I imagine that SSIS is adding an extra pair of quotation marks around the entire parameter. I don't think the following code would work, yet that is what is being created:

INSERT INTO [aging].[dbo].[ag_ageddebtor]
SELECT * FROM [aging].[dbo].[ag_ageddebtor_staging]
WHERE [Co Code] IN ('''8560'',''4956'',''5863'',''6245''')

Open in new window


My suggestion, therefore, is to have the entirety of the SQL code passed as a parameter, i.e. create the entire SQL string yourself, and use that in the Execute SQL. Then there would be no problems.
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

813 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