Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Does it sound OK or there is a better way?
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01325494
Message ID:
01325531
Views:
18
This message has been marked as the solution to the initial question of the thread.
>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform