Solved

SSIS Data Transform Design

Posted on 2010-08-17
12
813 Views
Last Modified: 2013-11-10
I am trying to design a part of an SSIS package (Data Flow Task)  that uses an excel spreadsheet for its input and output.  I am good on the source/destination setups.

I want to take one column from the input spreadsheet (userid) and use that in a query that returns the corresponding employee id from a database, replacing the userid with employee id in the output spreadsheet.

Can you advise me on the appropriate data transformations to use for this?

I am using the BI studio for SQL Server 2005.



0
Comment
Question by:harveystephenb
  • 4
  • 4
  • 3
  • +1
12 Comments
 
LVL 16

Accepted Solution

by:
vdr1620 earned 500 total points
Comment Utility
You will need to use a lookup transformation in between your source and destination To lookup for Employee Id that matches the User Id

http://msdn.microsoft.com/en-us/library/ms141821.aspx

In the Lookup
General Tab
Specify how to handle matching rows - Select Ignore Failure

Connection Tab
 you will need to select the Database and Then Select SQL Command from drop down and Write Down your SQL like SELECT UserId ,EmployeeID FROM TableName


ColumnsTab
Map the UserId of the Source To Destination and Check the box beside EmployeeId

And Lastly Map Matching output from Lookup to Destination
0
 
LVL 16

Expert Comment

by:carsRST
Comment Utility
Safest way is to import the Excel sheet in to a table (temp table in sorts) and do queries from it.  Reasoning is you can clean the data during import and dictate the data type of the data you're importing (can be some ambiguity when dealing with Excel columns).

0
 
LVL 30

Expert Comment

by:Reza Rad
Comment Utility
please let us know if you have problem in implementing vdr1620 method on Lookup  Transformation ,or if you want to use carsRST method about temp table.
0
 

Author Comment

by:harveystephenb
Comment Utility
I haven't been able to get the Lookup transformation to join with the User_Name input.  I get "Error at Data Flow Task [Lookup[1225] input column "User_Name" has data_type which cannot be joined."

I tried inserting a data conversion transformation in between the Excel source and the Lookup data transformation changed the output column type from DT_WSTR to DT_STR, DT_Text, and DT_NText.

Still same error message.

Was I destined to fail by following this advice?
0
 
LVL 30

Expert Comment

by:Reza Rad
Comment Utility
problem is: DT_NTEXT can not be used for lookup,
0
 

Author Comment

by:harveystephenb
Comment Utility
Should not DT_STR work?
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 16

Expert Comment

by:vdr1620
Comment Utility
the Lookup approach was an appropriate solution to your problem..and it would solve the issue that you have posted..  

DT_STR should work.. In order to convert DT_NText to DT_Str..you should convert it to text and then str as below

(DT_STR,Length,1252)(DT_Text,1252)(ColumnName)

Make sure that both the Source and Lookup column that you are trying to join have same data type

0
 
LVL 30

Expert Comment

by:Reza Rad
Comment Utility
DT_STR should work correctly.
do you receive any error? paste exact error message here
0
 

Author Comment

by:harveystephenb
Comment Utility
The column data type coming out of the excel file shows at DT_WSTR with length 255.  I tried using a data conversion transformation to change it to DT_STR with length 50.

The join column from the table I am querying from in my Lookup transformation is nvarchar(50).
I tried casting it in my query to varchar(50) hoping for a match.

I am not sure what you mean by

In order to convert DT_NText to DT_Str..you should convert it to text and then str as below

"(DT_STR,Length,1252)(DT_Text,1252)(ColumnName)".

Where do  I plug in such syntax?



0
 

Author Comment

by:harveystephenb
Comment Utility
Exact error message is:

 I get "Error at Data Flow Task [Lookup[1225] input column "User_Name" has data_type which cannot be joined."
0
 
LVL 16

Expert Comment

by:vdr1620
Comment Utility
Ok..I thought that you were trying to map a Ntext column to Str ..so i suggested to use the exp in derived column..never mind

Since,its a WSTR to nvarchar..you don't need change the column datatypes ...If you did that's fine too.. Some times it just happens that though you change the datatype the metadata of the column does not change ..so try to remove the column and add it again ..That might solve (if you are mapping right data types)

Also, use advanced editor and check the datatypes of th input and output columns..see the output columns have the data type that you have converted them to be... ( Rt click on transformation and Select Advanced editor)  
0
 
LVL 30

Expert Comment

by:Reza Rad
Comment Utility
also you can change datatype of input columns, in sources, right click , advanced editor, output column, change data type.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
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…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
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…

728 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

14 Experts available now in Live!

Get 1:1 Help Now