Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Where not exists best practice

Posted on 2013-02-04
5
Medium Priority
?
367 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
[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
  • 2
5 Comments
 
LVL 22

Accepted Solution

by:
plusone3055 earned 1000 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 1000 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
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 set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

705 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