sql server - how to check empty field in sql -


i have sql query shows address1 in field , address2 'address1,address2'.my query

(s.address1 + '  ,  ' + s.address2)as address1  

but when values in address2 blank shows 'address1,' , need show address1.how can remove comma

j w close, think, actual formula want, believe, is:

s.address1 + coalesce('  ,  ' + nullif(s.address2,''),'') address1 

(below not relevant, since op has said column value blank, not null)

have issue - above won't work (yet) because apparently have concat_null_yields_null set off. need turned on (usually setting ansi_nulls on), since:

in future version of sql server concat_null_yields_null on , applications explicitly set option off generate error. avoid using feature in new development work, , plan modify applications use feature.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -