Results 1 to 5 of 5

Thread: Renaming column

  1. #1
    Join Date
    Jun 2007
    Posts
    197

    Smile Unanswered: Renaming column

    ALTER TABLE ISMPBI CHANGE `PBICCGRFNUM` `PBICCGRFNUM1` BIGINT NOT NULL;


    this query to rename column name in my sql but not working in sql server
    so what is exact syntax to rename column

  2. #2
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    See the syntax for the ALTER TABLE command in the online manual

    Btw: don't use the backticks. They are a MySQL "speciality" and do not work with any other DBMS (actually they are not needed in MySQL as well)

  3. #3
    Join Date
    Jun 2007
    Posts
    197

    Smile

    MS SQL SERVER does not support RENAME syntax i cant find the syntax to rename column can any one give me exact syntax to rename column

  4. #4
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    The ALTER TABLE documentation links to the sp_rename function:
    Quote Originally Posted by manual
    Changes the name of a user-created object in the current database. This object can be a table, index, column, alias data type
    Example B: "renaming a column"

  5. #5
    Join Date
    Jun 2007
    Posts
    197

    Smile

    thanks


    here is exact syntax


    EXEC sp_rename 'BFMENUDEFINITION.[GROUP]', 'MENUGROUP', 'COLUMN';

    'BFMENUDEFINITION== tablename

    GROUP == old column

    'MENUGROUP'== new column

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •