Is it possible to test two EXISTS
conditions in a single IF
SQL statement? I've tried the following.
IF EXIST (SELECT * FROM tblOne WHERE field1 = @parm1 AND field2 = @parm2)
OR
EXIST (SELECT * FROM tblTwo WHERE field1 = @parm5 AND field2 = @parm3)
I've tried playing with adding additional IF
and parenthesis in there, but to no avail.
Can you help me out with the proper syntax?
You can use “there exist” when speaking of a non-singular amount or number of things. For example, “There exist several animals which have stripes on their hides.” You use “There exists” when speaking of a singular item or a single group of items.
The right form is: The file doeSn't exist. Gramatical explanation: always when you're forming a positive sentence about a 3rd person (singular only) in present simple tense, you have to add the letter s to the verb which describeS what he doeS.
A complete search of the internet has found these results: already exists is the most popular phrase on the web. More popular!
If SQL Server
IF EXISTS (SELECT *
FROM tblOne
WHERE field1 = @parm1
AND field2 = @parm2)
OR EXISTS (SELECT *
FROM tblTwo
WHERE field1 = @parm5
AND field2 = @parm3)
PRINT 'YES'
Is fine, note the only thing changed is EXISTS
not EXIST
. The plan for this will probably be a UNION ALL
that short circuits if the first one tested is true.
You missed an S at the end of EXIST
EXISTS, not EXIST
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With