?
Solved

SSIS 2008 - Passing a Variable/Parameter

Posted on 2014-04-23
8
Medium Priority
?
787 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
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…
Suggested Courses

762 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