In SQL, I am updating a Table : PlacedOrderDetails by mutiplying two columns and entering the mutiplied values to the Qty Column.
[Ship Qty] which is nvarchar(255)
[Size] which is nvarchar(255)
Resulted value goes to [Qty] which is float.
set Qty = [Ship Qty] * (cast(substring(Size, 1, patindex('%[^0-9]%', Size + '/') - 1) as float) * case when charindex('X', Size, 1) > 0 then
cast(substring(substring(Size, charindex('X', Size) + 1, len(Size)), 1, patindex('%[^0-9]%', substring(Size, charindex('X', Size) + 1, len(Size)) + '/') - 1) as float)
else 1 end )
WHERE Qty IS NULL
This is the Table value
Ship Qty Size Qty
2 100 EA 200
1 14.7 GM 14
Issue with my query is, decimal value of size column treated as round number and decimal part is ignored.
How to fix to treat whole number and decimal numbers equally?