Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
usafelix
Posting Yak Master
165 Posts |
Posted - 2015-01-01 : 22:22:24
|
I have one table and this field is character field with save data in below.Bonus_table->bonus_amt_field. Char(20)======================================Record information0 NullBlank 34NullBlankif i want to convert this character field => change to numeric field to display ,how to handle "Blank" and "null" record ? anyone can help give this sql query statement ?The result expect:0003400I try this query but wrong message : select cast(convert(numeric,3)bonus_amt) as bonus_amt from test Regards |
|
mandm
Posting Yak Master
120 Posts |
Posted - 2015-01-02 : 07:37:58
|
Try this.SELECT CAST(ISNULL(NULLIF(bonus_amt_field, ''), 0) AS int) FROM Test |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2015-01-03 : 12:57:22
|
orselect cast(case when bonus_amt is null or bonus_amt='' then 0 else bonus_amt end as numeric(3)) as bonus_amt from testMadhivananFailing to plan is Planning to fail |
|
|
|
|
|