Re: SQL import dup checking?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Dennis Burgess (dmburgess_at_surdyke.remvove.com)
Date: 11/04/04


Date: Thu, 4 Nov 2004 08:54:21 -0600

Thank you very much. It does work just like I wished!

Dennis

"David Portas" <REMOVE_BEFORE_REPLYING_dportas@acm.org> wrote in message
news:2o-dnWawGZCAFxTcRVn-rA@giganews.com...
> Possibly this is what you want:
>
> INSERT INTO Table2 (phone_no, date_col, ...)
> SELECT phone_no, CURRENT_TIMESTAMP, ...
> FROM Table1
> WHERE NOT EXISTS
> (SELECT *
> FROM Table2
> WHERE phone_no = Table1.phone_no
> AND date_col >= DATEADD(DAY,-30,CURRENT_TIMESTAMP))
>
> (untested)
>
> --
> David Portas
> SQL Server MVP
> --
>
>



Relevant Pages

  • Re: full join and nulls
    ... FROM Table1 AS T1 ... FULL JOIN Table2 AS T2 ... David Portas ... SQL Server MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: Latest date relationship
    ... CREATE TABLE Table1 ... CREATE TABLE Table2 (dt DATETIME PRIMARY KEY, ... SQL Server MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: Inner join question
    ... FROM Table1 AS T1 ... JOIN Table2 AS T2 ... David Portas ... SQL Server MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: Too much advanced query for a beginner
    ... FROM Table1 AS T1 ... JOIN Table2 AS T2 ... David Portas ... SQL Server MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: query to retrieve 2nd of TOP 2
    ... Ah, thank you all...I do have need help with a variation of this, ... though...my "table1" is already a join... ... > David Portas ... > SQL Server MVP ...
    (microsoft.public.sqlserver.programming)