Reputation: 988
Using sql server 2000
Table1
id value (float)
001 10.00
002
003
004 08.50
...
i want to check the value column, if is null then display 'NA'
Tried Query
Select id,
CASE WHEN value IS NULL then '-' else value end AS value
from table1
'
Select id,
isnull(value, '-') AS value
from table1
Both query showing error as "Error converting data type varchar to float."
How to solve this issue.
need query help
Upvotes: 1
Views: 1863
Reputation: 11571
use below query :
SELECT id, ISNULL( CAST(value as VARCHAR(25)), 'NA')) as [Value]
FROM tableName
Upvotes: 0
Reputation: 263683
Try
SELECT id, CAST(COALESCE(value, 'NA') as VARCHAR(25)) as [Value]
FROM tableName
Upvotes: 1
Reputation: 51494
Select id,
isnull(convert(varchar(20),value), '-') AS value
from table1
Upvotes: 3