dbTalk Databases Forums  

Merge Join Question

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Merge Join Question in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
imani_technology_spam@yahoo.com
 
Posts: n/a

Default Merge Join Question - 03-01-2006 , 12:04 PM






I'm trying to create a merge join that essentially does this:

SELECT DISTINCT a.CustomerID
,a.AddressID
,b.SalesOrderID
,b.SalesOrderDetailID
FROM
(
SELECT Sales.Customer.CustomerID
,Sales.CustomerAddress.AddressID
FROM Sales.Customer
INNER JOIN Sales.CustomerAddress
ON Sales.Customer.CustomerID = Sales.CustomerAddress.CustomerID
) a
INNER JOIN
(
SELECT Sales.Customer.CustomerID
,Sales.SalesOrderHeader.SalesOrderID
,Sales.SalesOrderDetail.SalesOrderDetailID
FROM Sales.SalesOrderHeader
INNER JOIN Sales.Customer
ON Sales.Customer.CustomerID = Sales.SalesOrderHeader.CustomerID
INNER JOIN Sales.SalesOrderDetail
ON Sales.SalesOrderHeader.SalesOrderID =
Sales.SalesOrderDetail.SalesOrderID
) b
ON a.CustomerID = b.CustomerID

Each subquery in my example ecomes a separate OLE DB source in my SSIS
package. When I run the T-SQL code, I get 122579 rows. However, when I
run the merge join, I only get 17 rows. Why is that? I believe the
join in the Merge Join package is correct.


Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Merge Join Question - 03-01-2006 , 03:32 PM






Hello imani_technology_spam (AT) yahoo (DOT) com,

Why are you handing this off to SSIS? You should be doing this (if it is
as simple as it looks) as a SQL Command in your Source Adapter.

In the Merge Join you are joining on CustomerID on each sorted input?

Why are you qualifying the DB? That costs you.


Have you counted the rows going in to each input?


Allan Mitchell
www.SQLDTS.com
www.SQLIS.com
www.Konesans.com

Quote:
I'm trying to create a merge join that essentially does this:

SELECT DISTINCT a.CustomerID
,a.AddressID
,b.SalesOrderID
,b.SalesOrderDetailID
FROM
(
SELECT Sales.Customer.CustomerID
,Sales.CustomerAddress.AddressID
FROM Sales.Customer
INNER JOIN Sales.CustomerAddress
ON Sales.Customer.CustomerID = Sales.CustomerAddress.CustomerID
) a
INNER JOIN
(
SELECT Sales.Customer.CustomerID
,Sales.SalesOrderHeader.SalesOrderID
,Sales.SalesOrderDetail.SalesOrderDetailID
FROM Sales.SalesOrderHeader
INNER JOIN Sales.Customer
ON Sales.Customer.CustomerID = Sales.SalesOrderHeader.CustomerID
INNER JOIN Sales.SalesOrderDetail
ON Sales.SalesOrderHeader.SalesOrderID =
Sales.SalesOrderDetail.SalesOrderID
) b
ON a.CustomerID = b.CustomerID
Each subquery in my example ecomes a separate OLE DB source in my SSIS
package. When I run the T-SQL code, I get 122579 rows. However, when
I run the merge join, I only get 17 rows. Why is that? I believe the
join in the Merge Join package is correct.




Reply With Quote
  #3  
Old   
imani_technology_spam@yahoo.com
 
Posts: n/a

Default Re: Merge Join Question - 03-02-2006 , 09:43 AM



I'm doing this as an experiment for work. My bosses wanted me to do a
quick comparison of a merge join to a T-SQL approach.

Yes, I am joining on CustomerID on each sorted input?

The rows going into each input are correct. The number of rows coming
out of the merge join is incorrect.

I'm not quite sure what you mean by "qualifying the DB."

Allan Mitchell wrote:
Quote:
Hello imani_technology_spam (AT) yahoo (DOT) com,

Why are you handing this off to SSIS? You should be doing this (if it is
as simple as it looks) as a SQL Command in your Source Adapter.

In the Merge Join you are joining on CustomerID on each sorted input?

Why are you qualifying the DB? That costs you.


Have you counted the rows going in to each input?


Allan Mitchell
www.SQLDTS.com
www.SQLIS.com
www.Konesans.com

I'm trying to create a merge join that essentially does this:

SELECT DISTINCT a.CustomerID
,a.AddressID
,b.SalesOrderID
,b.SalesOrderDetailID
FROM
(
SELECT Sales.Customer.CustomerID
,Sales.CustomerAddress.AddressID
FROM Sales.Customer
INNER JOIN Sales.CustomerAddress
ON Sales.Customer.CustomerID = Sales.CustomerAddress.CustomerID
) a
INNER JOIN
(
SELECT Sales.Customer.CustomerID
,Sales.SalesOrderHeader.SalesOrderID
,Sales.SalesOrderDetail.SalesOrderDetailID
FROM Sales.SalesOrderHeader
INNER JOIN Sales.Customer
ON Sales.Customer.CustomerID = Sales.SalesOrderHeader.CustomerID
INNER JOIN Sales.SalesOrderDetail
ON Sales.SalesOrderHeader.SalesOrderID =
Sales.SalesOrderDetail.SalesOrderID
) b
ON a.CustomerID = b.CustomerID
Each subquery in my example ecomes a separate OLE DB source in my SSIS
package. When I run the T-SQL code, I get 122579 rows. However, when
I run the merge join, I only get 17 rows. Why is that? I believe the
join in the Merge Join package is correct.



Reply With Quote
  #4  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Merge Join Question - 03-03-2006 , 04:24 PM



Hello imani_technology_spam (AT) yahoo (DOT) com,

You can use TSQL from within SSIS, you do not need to go all procedural and
row based. They compliment each other. TSQL will be quickest in a lot of
questions.

You specify the Db in your qiery. Why? If you execute this in the correct
Db you do not need to do this. SQL Server adds overhead when you do it.


Allan Mitchell
www.SQLDTS.com
www.SQLIS.com
www.Konesans.com

Quote:
I'm doing this as an experiment for work. My bosses wanted me to do a
quick comparison of a merge join to a T-SQL approach.

Yes, I am joining on CustomerID on each sorted input?

The rows going into each input are correct. The number of rows coming
out of the merge join is incorrect.

I'm not quite sure what you mean by "qualifying the DB."

Allan Mitchell wrote:

Hello imani_technology_spam (AT) yahoo (DOT) com,

Why are you handing this off to SSIS? You should be doing this (if
it is as simple as it looks) as a SQL Command in your Source Adapter.

In the Merge Join you are joining on CustomerID on each sorted input?

Why are you qualifying the DB? That costs you.

Have you counted the rows going in to each input?

Allan Mitchell
www.SQLDTS.com
www.SQLIS.com
www.Konesans.com
I'm trying to create a merge join that essentially does this:

SELECT DISTINCT a.CustomerID
,a.AddressID
,b.SalesOrderID
,b.SalesOrderDetailID
FROM
(
SELECT Sales.Customer.CustomerID
,Sales.CustomerAddress.AddressID
FROM Sales.Customer
INNER JOIN Sales.CustomerAddress
ON Sales.Customer.CustomerID = Sales.CustomerAddress.CustomerID
) a
INNER JOIN
(
SELECT Sales.Customer.CustomerID
,Sales.SalesOrderHeader.SalesOrderID
,Sales.SalesOrderDetail.SalesOrderDetailID
FROM Sales.SalesOrderHeader
INNER JOIN Sales.Customer
ON Sales.Customer.CustomerID = Sales.SalesOrderHeader.CustomerID
INNER JOIN Sales.SalesOrderDetail
ON Sales.SalesOrderHeader.SalesOrderID =
Sales.SalesOrderDetail.SalesOrderID
) b
ON a.CustomerID = b.CustomerID
Each subquery in my example ecomes a separate OLE DB source in my
SSIS
package. When I run the T-SQL code, I get 122579 rows. However,
when
I run the merge join, I only get 17 rows. Why is that? I believe
the
join in the Merge Join package is correct.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.