Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Using isnull() in joins

$
0
0

Let's say I have 2 tables - PurchaseOrderLine and PurchaseOrderLineAllocation.They both have a field named OrderLineID, but only 1 of them will ever be populated.

I need to join a 3rd table (OrderLine) to a 4th table (StockReceiptLine) via one of those 2 tables.

As it stands, the path would be:

  1. OrderLine.OrderLineID - PurchaseOrderLine.OrderLineID
  2. PurchaseOrderLine.PurchaseOrderLineID - StockReceiptLine.PurchaseOrderLineID

or

  1. OrderLine.OrderLineID - PurchaseOrderLineAllocation.OrderLineID
  2. PurchaseOrderLineAllocation.PurchaseOrderLineID - StockReceiptLine.PurchaseOrderLineID

I vaguely remember hearing isnull stops the optimizer from using indexes properly - would using isnull as part of the joins cause any kind of performance issues? If so, what would be the preferable option in this situation?

SQL
FROMOrderLineolLEFTJOINPurchaseOrderLine...

Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>