November 2, 2007 at 12:10 pm
hi
After modifying a column data type from int to varchar when I try to insert or update any
existing value with characters it gives me the following error
Syntax error converting the varchar value 'ABC1' to a column of data type int.
But the column has been changed from int to varchar.
Eg :
Employee table was created with employee type field as int which held values from 1...10
We had to change this field from int to Varchar.
Can someone provide help me solve this....
Thanks in Advance!
priya
November 2, 2007 at 8:24 pm
Heh... did you convert the correct column? Only way you can get that error is if the target column is actually an INT... double check the schema and make sure.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 16, 2007 at 2:11 pm
Maybe it's caused by an un-commited Transaction elsewhere in code run on the same database prior to your alter column code execution.
November 21, 2007 at 2:41 am
please check the schema and put the details in your reply
November 21, 2007 at 10:18 pm
Hi, This is because even thoguh you converted the data type from char to int, there would be some values which wouldnt have got converted to int. This is a typical scenario when you change a nvarchar datatype col to uniqueidentifier. You need to first run a test on the existing data to check if anyone of those are not converted to int. Convert them / delete and re-enter and then run your queries. This should work.
November 21, 2007 at 10:31 pm
If your getting the problem in select statement i am sure there will be an varchar data in the filed. Check the data.
November 22, 2007 at 12:28 am
Any chance you're trying to do your insert via a stored procedure that has not been updated to accept a varchar value as of yet?
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply