Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Where not exists best practice

Posted on 2013-02-04
5
Medium Priority
?
376 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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…

876 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