Quantcast
Channel: IF ELSE vs CASE WHEN
Viewing all articles
Browse latest Browse all 19

IF ELSE vs CASE WHEN

$
0
0

The only explanation I can think of that 2 different project teams programmed it during the years.

There is no T-SQL theoretical explanation for it.

if exists(select name from sysobjects where name = 'myfunc') select dbo.myfunc()
else select 0;
-- 0

select case when exists(select name from sysobjects where name = 'myfunc') then dbo.myfunc() else 0 end;
/*
Msg 4121, Level 16, State 1, Line 1
Cannot find either column "dbo" or the user-defined function or aggregate "dbo.myfunc", or the name is ambiguous.
*/


Kalman Toth Database & OLAP Architect IPAD SELECT Query Video Tutorial 3.5 Hours
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012




Viewing all articles
Browse latest Browse all 19

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>