Solved

Compare two tables for common string

Posted on 2014-02-14
6
281 Views
Last Modified: 2016-02-10
Hello there,

I want to do this in SSIS. My situation is as follows. I have Supplier table and a table which has the supplier/product name and other details about the products. Both the table have a common column called SupplierName. Now I want to compare these two columns and if they are same then insert the ID from the Supplier Table into this second table where all are in one table. I tried with SSIS see shot,but I get error
2-15-2014-11-00-18-AM.gif
0
Comment
Question by:zolf
  • 2
  • 2
6 Comments
 
LVL 16

Expert Comment

by:Surendra Nath
ID: 39861197
let us say the two tables in the first case Table1 and Table2.
the second table that you are talking about is TableA.

The common column here is ColumnX.

There are many ways to solve this issue, what I would do is to add a SQL task in the control flow and execute the below sql statement which will simplify the things

;WITH C AS 
(
  SELECT T1.ID ID FROM Table1 T1, Table2 T2 WHERE T1.ColumnX = T2.ColumnX
)
INSERT INTO TableA SELECT ID FROM C

Open in new window

0
 

Author Comment

by:zolf
ID: 39861203
by: Surendra Ganti

thanks for your comments. can you please explain what does the first line say ;WITH C AS
0
 
LVL 16

Expert Comment

by:Surendra Nath
ID: 39861231
that is called as common table expression (CTE)... this is newly introduced in SQL Server 2005
0
 

Author Comment

by:zolf
ID: 39862257
thanks for your comments. any idea why I get that error in my SSIS.I want to know the reason as to what I am doing wrong
0
 
LVL 37

Accepted Solution

by:
ValentinoV earned 500 total points
ID: 39864087
any idea why I get that error in my SSIS

The error says: "Row yielded no match during lookup", that means that the Lookup component did not find a matching value for one of the records in the batch.  That's probably not what you want because you'll have both matching and non-matching values coming in, right?  Open the properties of the Lookup transform and have a look at the dropdown.  It contains other options, like "Ignore failure" and "Redirect rows to no match output".

...and if they are same then insert the ID...

Are you sure you want to insert the ID, don't you mean update?  For update you'll have to use the OLE DB Command (not destination).
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
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…

920 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

15 Experts available now in Live!

Get 1:1 Help Now