Wednesday, September 9, 2009

Converting varchar to numeric for product size comparison

if the productsize is in varchar and needs to be used in the where condition for comparison of sizes it can be converted as below and used.The below case can we used in the where condition

case when productsize = '' or replace(productsize ,'"','') like '%[^0123456789.]%' then 0
else convert(numeric(18,2),replace(productsize ,'"',''))
end >= 1

1 comment:

  1. I prefer the combination of backups and recovery services, when dealing with how to execute a sql into a database

    ReplyDelete