Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Does it sound OK or there is a better way?
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01325494
Message ID:
01325531
Vues:
19
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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform