Solved

Where not exists best practice

Posted on 2013-02-04
5
347 Views
Last Modified: 2016-02-10
I have an SSIS that gets our email blast unsubscribe list.

It numbers in the 10's of thousands of course.

I have a local table that the records are inserted into.

With these numbers of emails, what is the best practice and cleanest way to insert where not exists?
0
Comment
Question by:lrbrister
  • 2
  • 2
5 Comments
 
LVL 22

Accepted Solution

by:
plusone3055 earned 250 total points
ID: 38850991
stackoverflow.com/questions/5288283/sql-server-insert-if-not-exists-best-practice
0
 

Author Comment

by:lrbrister
ID: 38851000
That link gives several answers.

I'm looking for a best practice answer....not a link. Sorry.
0
 
LVL 22

Expert Comment

by:plusone3055
ID: 38851011
no need to be sorry
when it comes to that there are several opinions. there is no end all know all heavenly "practice"

good luck :)
0
 
LVL 19

Assisted Solution

by:Rimvis
Rimvis earned 250 total points
ID: 38851267
Hi lrbrister,

Like plusone3055 said, I doubt there is some dedicated "best practice" source for stuff like that.

I would load incoming emails to the staging table, and then insert new records using LEFT JOIN, like in this example:

INSERT Competitors (cName)
SELECT DISTINCT Name
FROM CompResults cr LEFT JOIN Competitors c ON cr.Name = c.cName
WHERE c.Name IS NULL
0
 

Author Closing Comment

by:lrbrister
ID: 38851343
Thanks
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

Suggested Solutions

Title # Comments Views Activity
query execution hang 5 32
Live Storage Vmotion VMs with shared VMDK 10 61
Sql Server group by 10 30
Help to build a Proc... 6 23
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

832 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