#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    3
    Rep Power
    0

    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?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Location
    Montreal
    Posts
    92
    Rep Power
    11
    What enterprise Manager says when you edit the table properties?
    255 or 500?

    your sql statement seems fine...but go check with Enteprise Manager.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    3
    Rep Power
    0
    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.

IMN logo majestic logo threadwatch logo seochat tools logo