Solved

incremental load

Posted on 2014-10-14
3
130 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 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

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…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
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.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

726 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