Solved

SSIS. Execute SQL Task Parameter Mapping

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

713 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