casting varchar to numeric in case of null

casting, int, sql, varchar

Solution

You can use `ISNULL`:

convert(numeric(19,2), ISNULL(mdmaster.check_no, 0))as checkNbr,

This will make any `NULL` value be converted to `0.00`.

Here is a Live Demo

Problem

How do I handle this conversion if the value is null, so that it does not give the error "Error converting data type varchar to numeric". ``` convert(numeric(19,2), mdmaster.check_no)as checkNbr, ``` Thanx

Original source