'How can I change the datatype of a column from integer to text in SQL Server?

I need to change a database column from integer to string/text but I am not sure how to go about it.

This column is meant to store identification numbers, but recently the ID format changed and now the IDs contain ASCII characters as well (so with this change the new IDs cannot be stored as integers).

The application I am updating is written in Delphi 7 and uses the odbcexpress components for the SQL Server library.

Is it possible to use ALTER TABLE for this? Or does the data need to be copied to a new column as string, delete the old column, and rename the column to the old name?

Can you provide an example on how I might do this? I am not very familiar with the workings of SQL Server.

Thanks!



Solution 1:[1]

ALTER TABLE your_table MODIFY your_column_name varchar(255) null;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Suraj Rao