How to rename a column

  • Renaming a column in SSMS is not difficult. But how to do it in sql?

    I tried:

    USE MyDb

    ALTER TABLE MyTable

    ALTER COLUMN OldColumnName NewColumnName

    but this is a "no go" 🙁

    Should I drop the column and add a new one? Or is there an easier way to do it?

  • Henk:

    Look up sp_rename in SQL books online. Before renaming a column, check dependencies to see if you have any views, stored procedures, functions, etc that might depend on that column having a certain name.

    Bob

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • Bob,

    Thanks again :kiss:

    I'll have look

Viewing 3 posts - 1 through 2 (of 2 total)

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