Today,my customer asked me to import data to the database(SQL Server 2008 r2).
One of the columns whose type is varchar in the database,however unknow type in excel tab,records the code information.
when I imported the data from the excel to the database,I found that all the code details stored in the database changed to the type like '1.***xe**'.
After a small amount of trial,I found that we must Convert float to decimal before convert to varchar.
View Code
1 Select SUBSTRING ( cast ( Convert ( decimal ( 20 , 8 ),a.Code) as varchar ( 20 )), 1 , 2 ) from a