?
Solved

incremental load

Posted on 2014-10-14
3
Medium Priority
?
131 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 69

Assisted Solution

by:Scott Pletcher
Scott Pletcher earned 2000 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 2000 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
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
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Suggested Courses

764 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