SELECT CONVERT (varchar), CAST (@testFloat as Decimal (38,2))
SELECT STR (@testFloat, 38, 2)
Importing from Excel to sql2000, there is a list of "contacts" that have become float types, and I want to convert to nvarchar type, using the following statement
Select convert (nvarchar), convert (int, contact) from employee
Go
Data overflow, no!
Select convert (nvarchar), CONVERT (Decimal (11,0), contact) from employee
Go
Data Conversion Successful!
SELECT CONVERT (nvarchar), CAST (Contact as decimal (11,0)) from employee
Go
Data Conversion Successful!
SELECT STR (Contact form, 0) from employee
Go
Data Conversion Successful!
Summary, float---decimal----nvarchar
Convert
Cast
Str
about float conversion to varchar in SQL Server
A Float Type field, to convert to varchar, but after the decimal point is automatically deleted ... After the search can be obtained through the following conversion:
SELECT Cast (CAST (field as DECIMAL (20,7)) as VARCHAR from the table to be looked at
Or
SELECT CONVERT (VARCHAR), convert (DECIMAL (20,7), field) from the table to be searched
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/database/SQLServer/