>Hi everybody,
>
>Just want to verify if the syntax I used is OK or it can be done better (in Update I want to make sure they don't change name accidentally to already existing)
>
> IF EXISTS (SELECT * FROM dbo.Registration WHERE FirstName = @FirstName AND LastName = @LastName
> AND SiteID = (select SiteID from Registration where RegistrationID = @RegistrationID) and RegistrationID <> @RegistrationID)
>
>I'm not passing SiteID as a parameter.
>
>Thanks in advance.
IF EXSIST(SELECT * FROM dbo.Registration
INNER JOIN (SELECT SiteId FROM dbo.Registration where RegistrationID = @RegistrationID) Tbl1
ON dbo.Registration.SitedId = Tbl1.SiteId
WHERE dbo.Registration.FirstName = @FirstName AND
dbo.Registration.LastName = @LastName)
...
Not sure if this is better but I prefer that syntax.
You could test both ways, just put execution plan on :-)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.