Change Column Name

  • I need to change 500 column names on diffreent tables . Is there a way to do this programatically. How does the syscolumns table data relate back to the user table ?

  • First off renaming can and will affect any trigger, view, SP or other tiem referencing it so it is not recomended to do a bulk of them without first backing up the databases and testing each change. Now see BOL for SQL 2000 on

    sp_rename

    for 2000 detail.

    For 7 there is noting noted but thru a lot of digging around I found out about an undocumented DBCC command that will do it.

    DBCC renamecolumn

    the syntax is

    DBCC renamecolumn (object_name, old_name, new_name)

    Which object_name is the table, old_name is the column name now, and new_name is the new name to give it.

    This is undocumented and probably a holdover from 6.x or earlier. But again you are taking it on yourself to decide if this is the way to do it and are responsible for any issues that aricse in your environment.

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

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