March 8, 2005 at 10:33 pm
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/lPeysakhovich/performancetipspart2.asp
March 17, 2005 at 2:36 pm
Re: Situation 6
I don't get the use of variables and table type variables for what is essentially a set-based validation:
IF EXISTS (
SELECT external_item_cd
FROM inserted
WHERE external_item_cd IS NOT NULL
GROUP BY external_item_cd
HAVING COUNT(*) > 1
)
BEGIN
RAISERROR('Duplicate Records', 16, 1)
rollback
Return
END
Same with the 2nd step, why count to compare counts, when all you need to test for is existence
IF EXISTS (
SELECT 1
FROM Item As t1
INNER JOIN inserted As i
ON ( i.external_item_cd = t1.external_item_cd )
WHERE EXISTS (
SELECT 1
FROM Item As t2
WHERE t2.external_item_cd = t1.external_item_cd
AND t2.ItemID <> t1.ItemID
)
)
March 22, 2005 at 11:20 am
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy