.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Merge join and IsSorted for joining more than 2 inputs

Posted By:      Posted Date: October 15, 2010    Points: 0   Category :Sql Server

I have an XML file like this:


 <e1 myvalue="test">



   <detail value1="hello" value2="world" />

   <detail value1="

View Complete Post

More Related Resource Links

repeating merge joins using full outer join - should be possible without sort, but cannot get the co

Hello,   I am trying to combine several source tables with Merge Join.  For the Moment I have three source tables all already sorted in the source query and the is sorted property with the correct keys set. (its an aggregate query with group by and sort by the key columns) Then I do a merge join between two of the tables - with a full outer join. Then I just want to do another merge join with the output of the next result. but as the merge join do not combine the key columns into one column I need to add a derived column which substitute null values on the left side of the join with values from the right side of the join. The second merge then says only the left columns of the first merge join is sorted, but not the comined columns. If i Replace with a derived column the left side primary key columsn with the combinded key columns the next merge join says the input is not sorrted? But the output must be sorted. So how do I get the next merge join working without the ssis sort transformation? the data is sorted, but the component does not recognize the sorted data? I do not want to use (can use) the sort because there are flowing >= 500 Mio. records through the pipeline. Any help appreciated.   Hanneshttp://www.hmayer.net/

Merge Join: Full Outer Join - keep key values in case of no-match

I'm using the Merge Join to join several different incoming flows into one flow.  I've configured the joins to use a Full Outer Join because I need all records from all sources. In the case of a no-match, I want the component to keep the values of join key fields instead of setting them to NULL.  How can I achieve that?  (Activating the checkbox doesn't help, because that adds a new field to the output instead of re-using the existing one.)

Problem with Merge Join and condition splt trasnformations in SSIS 2008

  Hey, While working SSIS in 2008 we have encountering some weird problems with Merge, Merge Join and Condition Spilt transformations, here are the details... Condition Split and Merge Join and Condition Split: Please check the below diagram(not really just tried) for the complete details. Just FYI data is in sorted order   condition Split -> 420000      | 18                                                          | 419982  Merge Join(left)  -- src1(6000)      |10  Condition Split      |9     |1   the merge join transformation is not returning the complete 18 rows to the next transformation that's why we are missing 8 rows. But if we adds a sort transformation (getting warning as data is already sorted) before merge then complete 18 rows were passing to the condition split. Also tried modifing the source query just to return 18 rows then also it was passing the 18 rows to next trasnformation except with full load.       Merge: We have two sorted data sources and first one has 40000 records and second source have 12000 records and after the Merge transformation we have Condition Split transfor

Joining but only showing top entry for one join

  Lets say I have a join as follows: Select * from Table1 left outer join Table2 on Table1.ID = Table2.ID left outer join Table3 on Table1.ID = Table3.ID   Now, I want to be able to see every entry on Table1 and Table 2. However, I do not want Table3 to repeat its values. For example, I would like to see something like this:   Table1 ID Table2 ID Table3 ID 1 1 1 1   2 1   3 2 2 2 3 3 3 Is this possible?

Joining Dimtime table by a referenced Join create a problem



I am trying to join a dimtime table by a refernced join to an orderlines table which is the fact.

(the referenced join was defined in the relationship matrix of the cube ).

The referenced table is the ordersheader which had no measures in it but only used a linking table between those two other.

The join from the dimtime to the ordersheader  is done by date and from ordersheader to orderlines by orderid

The problem is that in the cube browser measures are shown as they were multiplied across all dates (like the join was done in a wrong way )

I have created an sql query and the logic is working just fine when quering directly from the DB


What am I doing wrong

Merge Join vs. T-Sql Inner Join?



I noticed this has been posted before - but could not get it working with the information on that post so here goes:

I have a T-Sql query that INNER JOINs 2 tables on one field - this returns 6,383 records.

(the one table contains 6,383 records and the other table 12 records)

However when I try to implement a data flow task with two data sources (one for each table) and sort the and then try to use the Merge Join transformation to sort and join them on the exact same field the result is 11,073 records.

What is going on here? logically this does not make sense to me ...

I.W Coetzer

Joining but only showing top entry for each join


I have a number of tables, whereby I want to join the tables to a parent table. My problem is that I wish to show every row of the table, but only show these rows once. This is hard to explain in text, so I have provided a example table below, which is the output I expect from the sql below. The #SI is the parent table.

(Note that I have only created the example with 4 tables. The actual number of tables will be more that this).

Output expected:

SI-1 SD1-1    
SI-2 SD2-1 RS2-1  
SI-2 SD2-2    
SI-3 SD3-1 RS3-1

Removing columns after Merge Join ?



I have the scenario (using a third party component) where certain columns must not be present as input.

I am doing a Full Outer - Merge Join.

This results in:



but now in some cases the LeftPK may be  null in other cases the RightPK may be null,

so i'm creating a derived column to check:

ISNULL(LeftPK) ? RightPK : LeftPK

and call this the TruePK

this all works however now i'm left with 3 columns

LeftPK; RightPK; TruePK

Is there some kind of transform (other than script task) that i can use to get rid of Left and Right PK columns before sending input to next third party component?

I.W Coetzer

Merge Join Failue


I'm working with SQL 2008 SSIS.  I'm trying to join two tables on email fields.  For test purposes I have copied some of the email addresses from table A to table B to insue I have matching values.  The OLE DB Source components each use a SQL query that sorts the output by the email addresses in ascending order.   For each of the two source components I've set the IsSorted property to True and set the Output Columns SortKeyPosition property to 1.  Within the SQL query I've also added trim functions to eliminate any possible extra spaces.  Since for testing purposes table B's email addresses are copies of email addresses in table A there is no issue with case.   When linking the two outputs using the Merge Join flow component I do not get any matches.

I've tried sorting using a Sort component rather than within the OLD DB Source query, but it seems to lock up on one of my flows (about 1.5 million records) and won't proceed.

At this point I don't know what else to try. 

Merge join in SSIS

how to use merge join in SSIS?

Any opinions on using Projection or explicit join syntax when joining entities in Linq to SQL?



I would like to know whether people use the join syntax OR projection when joining entities in LINQ to SQL queries. I have noticed that when using projection that a CROSS JOIN is in the generated SQL


var query =
from o in Orders
from  oi in o.OrderItems
where oi.OrderId == o.OrderId

generates SQL something like...

FROM [Customer].[Orders] AS [t0]
CROSS JOIN [Customer].[OrderItems] AS [t1]
WHERE ([t1].[OrderId] = [t0].[OrderId]) AND ([t1].[OrderId] = [t0].[OrderId])

whereas with explicit joins I get a clean inner join..

var query =
from o in Orders
join oi in OrderItems on o.OrderId equals oi.OrderId


FROM [Customer].[Orders] AS [t0]
INNER JOIN [Customer].[OrderItems] AS [t1] ON [t0].[OrderId] = [t1].[OrderId] 

I know using explicit joins over projection is frowned upon, but I am wary of those cross joins.

Just wondering what other folks preferences are when using joins in L2SQL.





joining 3 tables and using join to only include records not found in other table



I have 3 tables. I would like to get the number of records in table A that do not have cooresponding co_asset_ids in TABLE C but also need
to be be found in TABLE B and where the asset_id = 3. Said another way: If TABLE A record is in TABLE B and does not find a co_asset_id of 3 as found in table C then show these records.

assetno 4 and 5 are irrelevant but added to fill out the data more.

I know I could do this getting the co_asset_id column into TABLE A and then do some joins between TABLE A and TABLE C and leave TABLE B out, which I have done in the past. I would like to finally know if this can be done by using the 3 tables together in one elegant query.

The result of this query for this example data  would be:

Table A

Table B
assetno    co_asset_id
1              11
2              22
3              33
4              44
5              55


Merge Join in SSIS 2005 Vs 2008



I have a process which reads from 2 tables (using two connection managers) and "merge join" them to a third table by using left outer join.

This process is implemented on SSIS 2005 and SSIS 2008 identically, however, for some reason I get less records at the third table at the 2008 process.

When implementing this merge join on Sql Server 2008 and Sql Server 2005 I get the same result as I got at the SSIS 2005 process - so it seems like the problem is at the SSIS 2008 process.
I've checked the merge join properties - they look similar on 2005 and 2008.
Does anyone knows if the 2008 merge join object should be configured differently than the 2005 merge join?
I have nulls on some the fields that connect the two tables - do you think it's got to do with it?
What else can I check?

Mail Merge




I am after creating a mail merge documents from datasource and .dot template file on server side. Can you give me an idea how i will achive this?


Thanks in advance.



Syed Hussain



Merge SQL to Excel--Need .Net button to open on fly and have current SQL data!


           Hello all,
I do not know if this is the proper place to ask this, but my question is...
I have a SQL DB and I want to convert it to Excel Sheet (I did this using the wizard)!
In my aspx page I have a button.  So when I press this button I want the Excel sheet to open!  But I need the Excel sheet to show me the up to date information that is in the SQL DB.  

{ End Bracket }: Joining the Team


It's been more than a year since my words last floated across the pages of MSDN®Magazine. As readers of my blog probably know, my life's been interesting the past 12 months.

Matt Pietrek

MSDN Magazine January 2005

Join Two Tables and Prepare Report



            I have a select query which is executing well. Now, I want to add one more field to that query. That field is not in the current query table, It is in the another table.

How do I join those two tables and get that field value in the existing select query.?


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend