SELECT CONVERT (varchar), CAST (@testFloat as Decimal (38,2)))
SELECT STR (@testFloat, 38, 2)
Import from Excel to sql2000, there is a column "contact" has become a float type, I want to convert to nvarchar type, with 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 Success!
SELECT CONVERT (nvarchar), CAST (Contact as decimal (11,0)) from employee
Go
Data Conversion Success!
SELECT STR (Contact us, one, 0) from employee
Go
Data Conversion Success!
Summary, float---decimal----nvarchar
Convert
Cast
Str
About conversion of float in SQL Server to varchar a float type field, to be converted to varchar, but after the decimal point is automatically deleted ... After the search can be obtained by the following conversions:
SELECT Cast (CAST (field as DECIMAL (20,7)) as VARCHAR ()) from table to be checked
Or
SELECT CONVERT (VARCHAR), CONVERT (DECIMAL (20,7), field)) from the table to be looked up
SQL Server float format conversion string varchar method (GO)