|
|
Question : Something similar to VB's AndAlso / OrElse in SQL Server
|
|
Is there an operator in SQL Server that is similar to VB's AndAlso or OrElse? Something where if the first condition is true, it stops evaulating the statement?
IF Object_ID('tempdb..#MyTemptable') IS NULL or (SELECT SUM(MyValue) FROM #MyTemptable) IS NULL
If #MyTempTable hasn't been created, this will fail with an error. I've already coded around it, but I was wondering if there was such an operator in SQL?
Thanks, Landy
|
Answer : Something similar to VB's AndAlso / OrElse in SQL Server
|
|
You have to evaluate both things separately:
IF NOT(Object_ID('tempdb..#MyTemptable') IS NULL ) BEGIN If NOT (SELECT SUM(MyValue) FROM #MyTemptable) IS NULL BEGIN -- do your stuff here...
END END
|
|
|
|