Sunday 15 June 2014

sql - Replacing NULL and empty string within SELECT statement -


I have a column that can be either zero or empty space (i.e. '') value i am a valid value such as Together with 'UNKNOWN' I would like to change those values ​​I found that different solutions meet within the table only to modify the value. However, this is not an option in this case that the database is for the third party application that has been developed and / or very bad (in fact I think my router could do a better job). I am concerned that modifying the underlying data can melt in a smoking hole.

I have tried variations of the following commands:

  COALESCE (Address.COUNTRY, 'United States') - The empty string will not be replaced because this empty space (Country, '', 'United States') - empty string isnul (address country, 'United States') - works for zero but not empty string   

I know that I can use the CASE statement but hope Aँ have to rely on a much more elegant / efficient solutions

you believe when I say that I have been looking for solutions to their specific issues and I got no response. If I have something to overlook, please show me the path of light.

(Sorry to walk for a long time. I blame my mother.)

Try it

  COALESCE (NULLIF (address COUNTRY, ''), 'United States')    

No comments:

Post a Comment