Solved

Where not exists best practice

Posted on 2013-02-04
5
345 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

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
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 …
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

744 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

13 Experts available now in Live!

Get 1:1 Help Now