ALTER COLUMN DATATYPE

  • When I am trying to run given T-SQL on SQL2000 with database compatible-level 65, getting error near 'COLUMN' keyword.

    T-SQL: ALTER TABLE Stock_Master ALTER COLUMN width VARCHAR(25) NOT NULL;

    Where, original datatype of column 'width' in table 'Stock_Master' is INTEGER.

    Kindly HELP.

    Regards,

    Indra


    Regards,
    Indra

  • From BOL Alter Table subject :

    quote:


    ALTER COLUMN is not allowed if the compatibility level is 65 or earlier. For more information, see sp_dbcmptlevel.


  • One solution could be to add a second 'width_new' column with the correct datatype, copy all data over, remove the original 'width' column and rename the 'width_new' column.

  • Probs. is the column is primary key with more than 173 tables, so doing each and every table manually is not possible.

    Regards,

    Indar.

    quote:


    From BOL Alter Table subject :

    quote:


    ALTER COLUMN is not allowed if the compatibility level is 65 or earlier. For more information, see sp_dbcmptlevel.



    Regards,

    Indra


    Regards,
    Indra

  • I guess u can write a small script with a variable that takes the value from maybe a cursor or another query and runs against each table!!

    What do u think??

    Cheers!

    Arvind


    Arvind

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply