Reply to Re: Delete statement for a list of items with multiple columns identifying primary key

Your name:

Reply:


Posted by Hugo Kornelis on 07/07/06 21:16

On 7 Jul 2006 09:21:23 -0700, pb648174 wrote:

>I frequently have the problem where I have a list of items to delete in
>a temp table, such as
>
>ProjectId Description
>------------- ----------------
>1 test1
>2 test4
>3 test3
>4 test2
>
>
>And I want to delete all those items from another table.. What is the
>best way to do that? If I use two IN clauses it will do it where it
>matches anything in both, not the exact combination of the two. I can't
>do joins in a delete clause like an update, so how is this typically
>handled?

Hi pb648174,

DELETE FROM AnotherTable
WHERE EXISTS
(SELECT *
FROM #ItemsToDelete AS d
WHERE AnotherTable.ProjectId = d.ProjectID
AND AnotherTable.Description = d.Description)


--
Hugo Kornelis, SQL Server MVP

[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

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