From: Plamen Ratchev on
Andy B. wrote:
> 1. Select all rows that exist both in the TVP @Headlines and in the table
> [Headlines].[Headlines] and insert them into a table variable
> @ExistingHeadlines.

INSERT INTO @ExistingHeadlines (<columns>)
SELECT <columns> FROM @Headlines
INTERSECT
SELECT <columns> FROM [Headlines].[Headlines];

> 2. Select the rows that exist only in the TVP @Headlines and not in
> [Headlines].[Headlines] and insert them into a table variable
> @NonexistentHeadlines.
>

INSERT INTO @NonexistentHeadlines (<columns>)
SELECT <columns> FROM @Headlines
EXCEPT
SELECT <columns> FROM [Headlines].[Headlines];


--
Plamen Ratchev
http://www.SQLStudio.com