December 29, 2008 at 7:42 am
I have a field/column called A in table XX, initailly we decided to Varchar(50) as datatype for field/column A.
Now we want to change the datatype of A to int.
How can I do it? Also, field/column A does have data which is non-numeric.
Please suggest.
Thanks.
December 29, 2008 at 7:48 am
rename the column.
add a new column with the right name and data type.
update the column to the value where the field was numeric.
update the columns that were not numeric with some logicial value(zero?)
exec sp_rename 'XX.A',,'A_old','column'
ALTER TABLE XX Add A INT
UPDATE XX SET A=A_old where Isnumeric(A_old)=1
UPDATE XX SET A=0 WHERE Isnumeric(A_old)=0
dua_anshu (12/29/2008)
I have a field/column called A in table XX, initailly we decided to Varchar(50) as datatype for field/column A.Now we want to change the datatype of A to int.
How can I do it? Also, field/column A does have data which is non-numeric.
Please suggest.
Thanks.
Lowell
December 29, 2008 at 7:43 pm
dua_anshu (12/29/2008)
I have a field/column called A in table XX, initailly we decided to Varchar(50) as datatype for field/column A.Now we want to change the datatype of A to int.
How can I do it? Also, field/column A does have data which is non-numeric.
Please suggest.
Thanks.
What do you want to do with the non-numeric data?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply