Solved

SSIS. Execute SQL Task Parameter Mapping

Posted on 2014-10-23
3
248 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Here's a requirements document template for an integration project (also known as Extract-Transform-Load or ETL) based on my development experience as an SQL Server Information Services (SSIS) developer over the years.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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