How to rename a column in Azure SQL Data warehouse?

2021-01-07T04:35:13.833+00:00

Using below link we wrote a query to rename the column name in Azure SQL Data warehouse
https://learn.microsoft.com/en-us/sql/t-sql/statements/rename-transact-sql?view=aps-pdw-2016-au7#:~:text=Renames%20a%20user%2Dcreated%20table%2C%20a%20column%20in%20a%20user,(Azure%20SQL%20Database)%20statement.

rename object tablename column Col1 to Col2;

when we ran the above query it is throwing error message Incorrect Syntax near 'Column'

and also we ran a different query
Alter table tablename rename column Col1 to Col2;

the above query giving error message like Incorrect syntax near 'Rename'

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,373 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. PRADEEPCHEEKATLA 90,641 Reputation points Moderator
    2021-01-07T11:12:46.63+00:00

    Hello @Srikanth Yerramsetti (Avanade Inc) ,

    Welcome to the Microsoft Q&A platform.

    sp_rename (Transact-SQL) - This feature is in Preview for columns in user tables.

    Columns before Rename:

    54190-image.png

    The following example renames the MedallionID column in the tripoutput table to MID.

    EXEC sp_rename 'dbo.tripoutput.MedallionID', 'MID', 'COLUMN';  
    

    54338-image.png

    Columns after Rename:

    54387-image.png

    Hope this helps. Do let us know if you any further queries.

    ------------

    • Please accept an answer if correct. Original posters help the community find answers faster by identifying the correct answer. Here is how.
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification.
    2 people found this answer helpful.

  2. Abhishek Singh 6 Reputation points
    2021-04-03T04:31:19.923+00:00

    Is there any update on this issue?

    I am also facing the same error while performing RENAME of a column -
    Command : RENAME OBJECT databaseName.schemaName.TableName COLUMN oldColumnName TO newColumnName ;

    Msg 103010, Level 16, State 1, Line 130
    Parse error at line: 2, column: 46: Incorrect syntax near 'COLUMN'.

    0 comments No comments

  3. David Sartoris 1 Reputation point
    2021-04-22T17:26:06.873+00:00

    see https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-rename-transact-sql?view=sql-server-ver15

    "In Azure Synapse Analytics, sp_rename is in Preview and can only be used to rename a COLUMN in a user object in the dbo schema."

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.