T-SQL: Conver null or empty string to numeric value

I tried to use sum for a "varchar" type column in SQL table, and one day the code has error as there is a line contains empty value in this column and so the sum() function not working anymore.
So I add following function NULLIF(<clumn>,0)


The whole sum function is as below:
sum(CAST(NULLIF(AMOUNT,0) AS DECIMAL(22,2)))

Now I can get the sum amount value successfully.

Comments

Popular posts from this blog

Top JavaScript courses helping you develop SPFx webPart with ReactJS and AngularJS

Resolve error "AADSTS50012: Invalid client secret is provided" in MS Flow's HTTP connector

React Native: buffer is not defined