Pinku

Pinku

  • 1.4k
  • 302
  • 45.2k

Conversion of varchar to decimal

Aug 2 2024 8:07 AM

SELECT CASE WHEN CAST(Replace([Discount],'%','') as decimal) = 0 THEN '0.00%' WHEN CAST(Replace([Discount],'%','') as decimal) IS NULL THEN '0.00%' ELSE CAST(Replace([Discount],'%','') as decimal(5,2)) END AS Discount FROM Table

This script is not working nd giving error as "Error converting data type varchar to numeric" 

HOw to solve this issue


Answers (8)