You are here: Re: Update statement, then insert what wasn't available to be updated. « MsSQL Server « IT news, forums, messages
Re: Update statement, then insert what wasn't available to be updated.

Posted by Erland Sommarskog on 06/30/06 21:51

rhaazy (rhaazy@gmail.com) writes:
> ah ahaha all I needed to do was this...
> use my normal insert statement and add a where clause to the end of it
> like this..
>
> UpdateTblScanDetail....
>
> Insert into TblScanDetail
> where #temp.ID not in (select GUIID from tblScanDetail)
>
> doh! way too simple....

So, you issue is resolved then, and I don't have to scrutinize your
earlier posts.

Just a comment. I prefer to write the condition as:

NOT EXISTS (SELECT *
FROM tblScanDetail SD
WHERE SD.GUIID = #temp.ID)

There are two problems with NOT IN, that NOT EXISTS does not have:

1) you can get lost when there are NULL values involved.
2) works only with one-column conditions.

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

Navigation:

[Reply to this 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

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