Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SP with multiple tables and databases (insert & delete)
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00758108
Message ID:
00779579
Vues:
10
This message has been marked as a message which has helped to the initial question of the thread.
PMFJI, but your version with count(*) wouldn't work because SELECT COUNT(*) always returns result (0 if no records meets condition) so IF EXISTS will always evaluate to True.
It doesn't make a difference if you specify one field or * because query optimizer is smart enough to realize that internal select in EXISTS doesn't retrieve any data but checks if any records for specified conditions exists. IF EXISTS in SQL Server is similar to SEEK in VFP because it doesn't retrive data.


>Hi Mike,
>
>Sorry for the old thread. I was just re-reading it and I have a question:
>
>would it be better to change
>
IF EXISTS (SELECT * FROM cart WHERE cartid = @cartID)
>
>to
IF EXISTS (SELECT count(*) FROM cart WHERE cartid = @cartID)
(or select just one field)
>
>Or this doesn't matter at all for this kind of check?
>
>Thanks a lot in advance.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform