Unable to change type of a table column.

Mouktik_B
Tera Contributor

I have a column inside a table of integer type but can't change its type. Only integer shows up when I try to change the type. what could be solution?

1 ACCEPTED SOLUTION

Bhimashankar H
Mega Sage

Hi @Mouktik_B ,

 

You won't be able to change the data type once column is created for your scenario. Here best to create new column with your specified data type.

 

If you want to retain the data then using bg script or fix script you can move/copy the data in your new column, apply proper data type conversion when data moving. Later based on your need either keep for any future use or delete the column.

 

Thanks,
Bhimashankar H

 

-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!

View solution in original post

9 REPLIES 9

Bhuvan
Tera Sage

@Mouktik_B 

 

If you have the field populated with data in underlying table, system will not allow to change the data type.

 

If you need to retain the data, follow this method. You need to create a temporary field, copy the data from original_field to temporary_field and delete the data from original field, change the data type and migrate data from temporary field to original field and finally delete the temporary field.

 

If you do not want to retain data, clean up the field value and change the data type or delete the existing field and create new field with required data type.

 

If this helped to answer your query, please mark it helpful & accept the solution. 

 

Thanks,

Bhuvan

@Mouktik_B 

 

Please see below for steps,

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1584315

 

If this helped to answer your query, please mark it helpful & accept the solution. 

 

Thanks,

Bhuvan

@Mouktik_B 

 

Did you get a chance to review this ?

 

If my response helped to answer your query, please mark it helpful & accept the solution.

 

Thanks,

Bhuvan

Bhimashankar H
Mega Sage

Hi @Mouktik_B ,

 

You won't be able to change the data type once column is created for your scenario. Here best to create new column with your specified data type.

 

If you want to retain the data then using bg script or fix script you can move/copy the data in your new column, apply proper data type conversion when data moving. Later based on your need either keep for any future use or delete the column.

 

Thanks,
Bhimashankar H

 

-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!

Bhimashankar H
Mega Sage

Hey @Mouktik_B ,

 

I hope you saw my reply. 


If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. It will help future readers as well having similar kind of questions and close the thread.

Thanks,
Bhimashankar H