Solved

incremental load

Posted on 2014-10-14
3
125 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:ScottPletcher
ScottPletcher 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:
ScottPletcher 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
In this article I will describe the Copy Database Wizard 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.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

930 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now