September 11, 2012 at 6:53 am
I've a table with one column as varchar(50). This table is hugely populated. I want to alter this column to datatype float. While altering it gives me the following error:
Error converting data type varchar to float.
Kindly let me know what can be done as quick fix ?
September 11, 2012 at 7:31 am
sqlnaive (9/11/2012)
I've a table with one column as varchar(50). This table is hugely populated. I want to alter this column to datatype float. While altering it gives me the following error:Error converting data type varchar to float.
Kindly let me know what can be done as quick fix ?
Can you post a sample of the data? You will have to find the rows which contain data which cannot be implicitly converted to float and deal with them.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 11, 2012 at 7:43 am
You are going to have to identify the data that won't convert.
Modify as needed and run this:
select
*
from
dbo.YourTable
where
ColumnToConvert like '%[^0-9]%';
September 11, 2012 at 8:16 am
Thanks both Chris and Lynn. I was checking and found that there were few records having populated as 'NULL' string. Thats why it was causing issue. Rectified it and now all is fine. Thanks once again.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply