Case study 13: Lucky number to table and column rename
  • Platform: HP-UNIX 11, Tru64, Windows
  • Sybase ASE version: 12.5.x
  • Background story: Several times I had a problem with same script. There is always something missing. So here it is. Rename table or rename column. Written here only because of archive purposes
  • Task: Write a script which renames table or renames column.
  • Solution: SQL scripts are given below:

    sp_rename "OLD_TABLE_NAME", "NEW_TABLE_NAME"
    go

    sp_rename "TABLE_NAME.OLD_COLUMN_NAME", NEW_COLUMN_NAME
    go

  • Remark: Be aware that in script two, which renames column, there is no table name in front of NEW_COLUMN_NAME. This is most common mistake.
   
  powered by myself. DBA-Sybase 2006