Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01325494
Message ID:
01325538
Views:
17
>>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 :-)

Looks better. In VFP the INNER JOIN syntax seems to slightly out-perform the other syntax. See Re: Getting most recent orders? Thread #1249462 Message #1324705 and I would appreciate your tests as well.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View