>>Is this (see code snippet below) the most efficient way to check if there is a row in the table with a given PK value?
>>
>>
>>IF ( SELECT COUNT(*) FROM MyTable WHERE PkId = @PkId ) < 1
>>BEGIN
>> RAISERROR('The record you are looking for aint there.',16,1)
>>END
>>
>>
>>Einar
>
>
IF NOT EXISTS(SELECT [PK] FROM [MyTable] WHERE [PK] = @PK) ...
>
>If this query is used a lot, there should be a nonclustered index on PK.
Thanks. Your way looks cleaner than my code.
Einar
Semper ubi sub ubi.