{"id":85,"date":"2009-10-27T16:06:07","date_gmt":"2009-10-27T15:06:07","guid":{"rendered":"http:\/\/blog.rabihtawil.com\/?p=85"},"modified":"2009-10-27T16:06:07","modified_gmt":"2009-10-27T15:06:07","slug":"coalesce-another-isnull-method","status":"publish","type":"post","link":"http:\/\/www.raytawil.com\/?p=85","title":{"rendered":"Coalesce another IsNull method"},"content":{"rendered":"<blockquote>\n<pre><em><strong><em><strong>COALESCE ( expression [ ,...n ] )\n\n<\/strong><\/em><\/strong><\/em><\/pre>\n<\/blockquote>\n<p>Coalesce is Equivalent with<\/p>\n<blockquote><p>CASE    WHEN (expression1 IS NOT NULL) THEN expression1    WHEN (expression2 IS NOT NULL) THEN expression2    &#8230;    ELSE expressionN END<br \/>\nEND<\/p><\/blockquote>\n<p>My little experiment with coalesce<\/p>\n<blockquote><p>DECLARE @i VARCHAR(20)<br \/>\nDECLARE @exp2<br \/>\nSET @exp2 = NULL<\/p>\n<p>SET @i = null<br \/>\nSELECT COALESCE (@i + &#8216; more;&#8217;, &#8216;It&#8221;s Null&#8217;) &#8211;result [It&#8217;s Null]<br \/>\nSELECT COALESCE (@i , &#8216; more;&#8217;, &#8216;Stranger&#8217;) &#8211;result [ more;]<br \/>\nSELECT COALESCE (@i , @exp2, &#8216;Stranger&#8217;)  &#8211;result [Stranger]<\/p>\n<p>SET @i = &#8216;Something&#8217;<br \/>\nSELECT COALESCE (@i + &#8216; more;&#8217;, &#8216;It&#8221;s Null&#8217;) &#8211;result [Something more;]<br \/>\nSELECT COALESCE (@i , &#8216; more;&#8217;, &#8216;Stranger&#8217;) &#8211;result [Something]<br \/>\nSELECT COALESCE (@i , @exp2 , &#8216;Stranger&#8217;) &#8211;result [Something]<\/p><\/blockquote>\n<p>As you see if I use case and combine it with null function it\u2019ll need more than one line. Coalesce is very useful and helpful in above case.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>COALESCE ( expression [ ,&#8230;n ] ) Coalesce is Equivalent with CASE WHEN (expression1 IS NOT NULL) THEN expression1 WHEN (expression2 IS NOT NULL) THEN expression2 &#8230; ELSE expressionN END END My little experiment with coalesce DECLARE @i VARCHAR(20) DECLARE @exp2 SET @exp2 = NULL SET @i = null SELECT COALESCE (@i + &#8216; more;&#8217;, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[110],"tags":[],"_links":{"self":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts\/85"}],"collection":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=85"}],"version-history":[{"count":0,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts\/85\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=85"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=85"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}