I am using SSIS (SQL Server 2008) to lookup values from a table. I wanted to know if the following are possible:
Question 1
Lookup Table 1
Manager_Name EMP_UNIT Job_Profile_ID
AAA SALES 27
BBB HR 28
AAA SALES 29
I have to pass the ‘Manager_Name ‘and ‘EMP_UNIT ‘value in the Lookup table and fetch
Job Profile ID in Comma separated format.
Like I will pass the Values ‘AAA’ and ‘SALES’ and I want the return value as 27,29
How will I do this?
Question 2
Lookup Table 2
Job_Profile_ID Job_Name
27 Jr. Salesman
28 Sales Manager
29 Sr. Salesman
I have to pass the Job Profile ID values in Comma separated format (27, 29) and
I want the return value in Comma separated format (Jr. Salesman, Sr. Salesman).
Is this possible in SSIS?
Environment details:
MS SQL Server integration services (bids) 2008 on windows 2008 server
any help is appreciated,
Thanks
If I understand your question correctly, you need the list of job names for a given manager and employee unit combination. If that is the case, you need a stored procedure that can give the list of job names in a comma separated value.
In my opinion, two lookup transformation tasks seems to be a overkill.
Based on the data provided in the question, the section Create and populate tables provide the sample data.
Create the following stored procedure
dbo.GetManagerJobProfilesthat will takeManager_NameandEmp_Unitas input parameters and will return the list of matching job names for the given parameters as a comma separated list. This stored procedure uses FOR XML clause to generate the comma separated values. Since the comma is appended at the beginning, we have to truncate the first comma from the list. Hence, the substring function is used to do that job to give a cleaner output.Screenshot #1 shows the sample data in the tables dbo.Managers and dbo.Jobs.
Screenshot #2 shows the stored procedure output for two different sets of parameters.
If I have to use this in an SSIS package, I would get the list of distinct Manager_Name and Emp_Unit combinations using an Execute SQL Task and will populate the resultset into an SSIS Package variable of data type Object.
I will then loop through the object variable using
Foreach loop containerwithForeach ADO enumerator. Within the Foreach loop container, I will place aData Flow Task. Within the data flow task, I will place anOLE DB Sourcewhich will use the stored procedure as the source. For each Manager_Name and Emp_Unit combination being looped through, the values will be passed as parameters to the OLE DB Source to fetch the Job name values.Hope that helps.
Create and populate tables: This structure is based on the data provided in the question.