Solved

Compare two tables for common string

Posted on 2014-02-14
6
284 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Here's a requirements document template for an integration project (also known as Extract-Transform-Load or ETL) based on my development experience as an SQL Server Information Services (SSIS) developer over the years.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to shrink a transaction log file down to a reasonable size.

809 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