{"id":529,"date":"2012-04-27T01:08:42","date_gmt":"2012-04-26T20:08:42","guid":{"rendered":"http:\/\/www.esearing.com\/v2010\/?p=529"},"modified":"2012-04-27T01:08:42","modified_gmt":"2012-04-26T20:08:42","slug":"sql-using-case-to-identify-blanks-vs-nulls","status":"publish","type":"post","link":"https:\/\/www.esearing.com\/v2010\/2012\/04\/sql-using-case-to-identify-blanks-vs-nulls\/","title":{"rendered":"SQL using case to Identify blanks vs NULLs"},"content":{"rendered":"<p>I had a strange issue driving me nuts today. I had data with null values and could use isNull to capture most of them and assign a new value to the field. However about 10 records would not accept the isnull logic. Finally after about 2 hours of beating the keyboard to death I finally realized the field was not null but contained blanks. So here is the code that can help if you run into this same situation. <\/p>\n<p><code><br \/>\nselect CASE _fieldname_<br \/>\n   When NULL Then 'missing'<br \/>\n   When '' Then 'spaces'<br \/>\n   Else _fieldname_<br \/>\n   END as _fieldname_<br \/>\nfrom tablename <\/p>\n<p>* <em>Replace the _fieldname_ with your fieldname containing blanks and nulls<\/em><br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I had a strange issue driving me nuts today. I had data with null values and could use isNull to capture most of them and assign a new value to the field. However about 10 records would not accept the &hellip; <a href=\"https:\/\/www.esearing.com\/v2010\/2012\/04\/sql-using-case-to-identify-blanks-vs-nulls\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,24,14],"tags":[31,30,32,29],"class_list":["post-529","post","type-post","status-publish","format-standard","hentry","category-code","category-snippets-quick-code-tips-for-single-elements-attributes-or-details","category-sql","tag-blanks-in-data","tag-null-data","tag-null-vs-blanks","tag-sql-case"],"_links":{"self":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts\/529","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/comments?post=529"}],"version-history":[{"count":3,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts\/529\/revisions"}],"predecessor-version":[{"id":533,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts\/529\/revisions\/533"}],"wp:attachment":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/media?parent=529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/categories?post=529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/tags?post=529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}