March 2nd, 2004, 09:15 AM
Changing table column size
I'm new to mssql.
I need to change the size of a column of a table from char(255) to char(500). I used the line:
alter table table_name alter column column_name char(500)
When I run that command, I get a message that it was sucessful. However, when I try to enter data into the changed column, the number of characters I can enter is still 255. I check the information schema for the column and the 'character_maximum_length' field is 500.
What is the problem here? Is the maximum allowable length for char 255? How can I get a column to have 500 characters?
March 2nd, 2004, 03:59 PM
What enterprise Manager says when you edit the table properties?
255 or 500?
your sql statement seems fine...but go check with Enteprise Manager.
March 24th, 2004, 05:41 AM
xiphias, when you alter a columns size wich is of type char and for example you change from 20 to 30,
and you have in it 15 charcters, after the change it will be filled with another 15 space characters to complete 30.
this is the way with char so try or to change it to varchar wich is better or if you trim the string inside or if you edit it directly, go to the end with the 'End' key and delete the spaces wich complete the string.
Please reply if that helps, i got the same error you got, i solved it by changing to varchar but didnt try to solve it keeping the char type.