sql server - Sql query to convert nvarchar to int -
i have query total amount of column using aggregate function. column data type nvarchar(max). how can convert integer?
i have tried this:
select sum(cast(amount int)), branch tblproducts id = 4 group branch
...but i'm getting:
conversion failed when converting nvarchar value '3600.00' data type int.
3600.00 not integer cast via float first
sum(cast(cast(amount float) int))
edit:
why float?
- no idea of precision or scale across rows: float lesser evil perhaps
- empty string cast 0 float, fails on decimal
- float accepts stuff 5e-02, fails on decimal
Comments
Post a Comment