Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SSIS 2008 - Passing a Variable/Parameter

Posted on 2014-04-23
8
Medium Priority
?
797 Views
Last Modified: 2016-02-10
Hi,

I would like to know if I am passing a parameter correctly and how you can see what is being passed?

I have this SQLStatement:
SELECT DISTINCT
      FILE_ID
  FROM DATABASE_TABLES
  Where
      TBL_STAT = 'purge_elig' And
      TBL_Typ = 'Claim' And
      TBL_NM not in (Select Distinct TBL_NM From DATABASE_TABLES Where TBL_TYP = 'CLAIM' and TBL_STAT = 'ACTIVE')
Go
SELECT DISTINCT
      FILE_ID
  FROM DATABASE_TABLES
  Where
      TBL_STAT = 'purge_elig' And
      TBL_Typ = 'CLAIM_ITEM' And
      TBL_NM not in (Select Distinct TBL_NM From DATABASE_TABLES Where TBL_TYP = 'CLAIM_ITEM' and TBL_STAT = 'ACTIVE')
Go
SELECT DISTINCT
      FILE_ID
  FROM DATABASE_TABLES
  Where
      TBL_STAT = 'purge_elig' And
      TBL_Typ = 'CLAIM_FACILITY_DETAIL' And
      TBL_NM not in (Select Distinct TBL_NM From DATABASE_TABLES Where TBL_TYP = 'CLAIM_FACILITY_DETAIL' and TBL_STAT = 'ACTIVE')
      

I want to pass the FILE_ID
FILE_ID has a datatype set to Int
I am using Execute SQL Task
ResultSet: Single row
It is a OLE DB Connection Type
I have it in a Foreach Loop Container

So I go to the:
Result Set
Add Variable
Name: FILE_ID
Namespace: User
Value Type: Int32
Value: 0
<Ok>


Is this all correct?
How do I check what is being passed?

Thanks...
0
Comment
Question by:Amour22015
[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
  • 4
  • 3
8 Comments
 
LVL 8

Accepted Solution

by:
ProjectChampion earned 1000 total points
ID: 40019813
Hi Amour22015,
First the ResultSet for the 'Execute SQL' component should be set to 'Full ResultSet' because the queries you've typed above will potentially return more than just one row - unless you change the distinct to "Top 1" if that's what you want.  But assuming that you want to pass all returned File_Id's to a 'For Loop' then you should select full result set. Then Choose a Foreach Loop Container of type ADO Enumerator, create a user variable of type Object and set the ADO object source variable attribute of the Foreach Loop to this variable. Go to the variable mappings and set the (User::File_ID, 0) as (Variable, Index).

You can set a breakpoint for the foreach loop and check the parameter passed to the foreach loop at the beginning of each iteration in debug mode..
0
 

Author Comment

by:Amour22015
ID: 40019864
Ok,

Sorry I am very new to all this...

I have set the resultSet to 'Full ResultSet' Within the Execute SQL Task

Now I am at the Foreach Loop Editor, but I don't see the option: "Container of type ADO Enumerator" I also looked under properties and did not see that option there either?  I currently have a Foreach Loop Container, is that the correct one?


Please explain closer:
create a user variable of type Object and set the ADO object source variable attribute of the Foreach Loop to this variable. Go to the variable mappings and set the (User::File_ID, 0) as (Variable, Index).


Thanks
0
 
LVL 8

Expert Comment

by:ProjectChampion
ID: 40019889
No problem, add a "Foreach Loop Container", then right+click and "Edit..."; in the "Collection" tab set the Enumerator attribute to "Foreach ADO Enumerator" and the "ADO Object Source Variable" to a new variable of type Object that would be the resultset of the previous 'Execute SQL Task' component.
Then go to the "Variable Mappings" tab and follow on as previously explained. Let me know if it's still not clear.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 21

Expert Comment

by:Alpesh Patel
ID: 40019965
Yes,
moreover, put break point on Execute SQL task and see the variable value in Local Tab. You will see assigned value to variable.
0
 

Author Comment

by:Amour22015
ID: 40019995
On this:

Go to the variable mappings and set the (User::File_ID, 0) as (Variable, Index).

I went to the variable mappings of the Foreach Loop Container

But I only see:
Variable:  I selected the newly created variable
Index: is set to 0

But I don't see:
(Variable, Index).


Also do I not have a parameter/variable within the Execute SQL Task or do I just remove?

Thanks
0
 

Author Comment

by:Amour22015
ID: 40020000
Never mind

This is just a header that you mentioned
(Variable, Index).


Thanks
0
 

Author Closing Comment

by:Amour22015
ID: 40020073
Great thanks
0
 
LVL 8

Expert Comment

by:ProjectChampion
ID: 40020085
Glad that you solved your problem.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
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…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

636 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