Home Forums SQL Server 2008 T-SQL (SS2K8) Function to replace string 'NULL' with null value RE: Function to replace string 'NULL' with null value

  • Hi

    Here is one way without using a CASE:

    DECLARE @gross_amount VARCHAR (10) = '18'

    SELECT CAST(COALESCE(NULLIF(@Gross_Amount,'NULL'),@gross_amount) AS DECIMAL(18,2))

    Andy

    ==========================================================================================================================
    A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila. Mitch Ratcliffe