Solved

Compare two tables for common string

Posted on 2014-02-14
6
278 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
Comment Utility
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
Comment Utility
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
Comment Utility
that is called as common table expression (CTE)... this is newly introduced in SQL Server 2005
0
 

Author Comment

by:zolf
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
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.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

771 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

11 Experts available now in Live!

Get 1:1 Help Now