Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SP with multiple tables and databases (insert & delete)
Message
 
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00758108
Message ID:
00779579
Views:
16
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--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform