Solved

incremental load

Posted on 2014-10-14
3
127 Views
Last Modified: 2014-10-15
I want to do an incremental load to table LookupTable from table ImportTable.
I am doing it as follows:

Insert into LookupTable 
Select distinct A.AID, A.BID, A.CID
From ImportTable I
left outer Join LookupTable A on A.AID = I.AID
where 1=1
and A.AID is null
and I.BID <> ''

Open in new window


Is this the best way for performance?
Please suggest if there is a better way to do this.

Thanks.
0
Comment
Question by:patd1
  • 2
3 Comments
 
LVL 69

Assisted Solution

by:Scott Pletcher
Scott Pletcher earned 500 total points
ID: 40381022
Insert into LookupTable
Select distinct I.AID, I.BID, I.CID
From ImportTable I
left outer Join LookupTable A on A.AID = I.AID
where 1=1
and A.AID is null
and I.BID > ''
0
 

Author Comment

by:patd1
ID: 40381948
Thanks Scott. I had a typo in my first line of code.
Does it make any difference in performance or otherwise if I use merge or Intersect/except clauses instead of left outer join?

Insert into LookupTable 
Select distinct I.AID, I.BID, I.CID
From ImportTable I
left outer Join LookupTable A on A.AID = I.AID
where 1=1
and A.AID is null
and I.BID > ''

Open in new window


Thanks.
0
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 500 total points
ID: 40382191
Usually not.  SQL will often generate the same plan anyway.  But, you could test that without even running the code.  Look at the query plan for the code above and the query plan for the EXCEPT version and see if they match :-).
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
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 combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

856 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