Solved

incremental load

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

708 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

17 Experts available now in Live!

Get 1:1 Help Now