Reply to Re: MS SQL copy new and modified rows from TABLE1 to TABLE2

Your name:

Reply:


Posted by Roy Harvey on 08/21/07 11:01

On Tue, 21 Aug 2007 01:29:46 -0700, Yas <yasar1@gmail.com> wrote:

> INSERT INTO
> Table2(STATUS,attribute15,email,lastname1,lastname2,name,company,startDate)
> SELECT 'Active' AS STATUS, b.Attribute15, b.email, b.lastname1,
> b.lastname2, b.name,
> b.company, b.startDate
> FROM Inserted b LEFT OUTER JOIN
> Table2 a ON b.Attribute15 = a.Attribute15
> WHERE a.Attribute15 IS NULL

>Just out of curiosity how would you modify the above to use
>NOT EXISTS ?

INSERT INTO Table2
(STATUS,attribute15,email,
lastname1,lastname2,name,
company,startDate)
SELECT 'Active' AS STATUS, b.Attribute15, b.email,
b.lastname1, b.lastname2, b.name,
b.company, b.startDate
FROM Inserted b
WHERE NOT EXISTS
(SELECT * FROM Table2 a
WHERE b.Attribute15 = a.Attribute15)

Roy Harvey
Beacon Falls, CT

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация