Rename a column name (containing dot in it) of a table

Gulhasan.Siddiquee 101 Reputation points
2023-03-17T10:24:35.3133333+00:00

I want to change a column name of a table . But issue is that column name is containing dot in it . which is creating issue while I am executing below statement.:-

I can not drop the table as it contains huge and important data

expecting Column name = mobileappperformanceappid_app-perf-app-name
current column name = mobileappperformanceappid.app-perf-app-name
EXEC sp_rename 'source.tbalename.mobileappperformanceappid.app-perf-app-name' , 'mobileappperformanceappid_app-perf-app-name','COLUMN';

Azure SQL Database
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.
4,402 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,614 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,587 questions
{count} votes

Accepted answer
  1. ShaktiSingh-MSFT 13,516 Reputation points Microsoft Employee
    2023-04-04T12:42:40.71+00:00

    Hi Gulhasan.Siddiquee

    Thanks for trying afresh the queries.

    The problem looks strange, I tried to follow the same naming convention for the schema and tables and could execute commands successfully as shown below: User's image

    User's image

    The issue in your Azure Data Studio looks strange and not expected. I would recommend you to please file a support ticket for deeper investigation and in case if you don't have a support plan, do let us know here so that we can check on other options to unblock you.

    Thanks


3 additional answers

Sort by: Most helpful
  1. Bjoern Peters 8,781 Reputation points
    2023-03-21T17:14:20.39+00:00

    Hi Gulhasan,

    Welcome to Q&A Forum; this is a great place to get support, answers, and tips.

    Thank you for posting your query; I'll be more than glad to help you out.

    I was able to change the name of your column ;-)

    EXEC sp_rename 'dbo.demotable.[mobileappperformanceappid.app-perf-app-name]' , 'mobileappperformanceappid_app-perf-app-name','COLUMN';
    

    You have to set only the column name in brackets.

    That worked for my environment... SQL Server 2019 Developer (Ubuntu) should also work in your env.

    I hope my answer is helpful to you,

    Your

    Bjoern Peters

    If the reply was helpful, please upvote and/or accept it as an answer, as this helps others in the community with similar questions. Thanks!


  2. ShaktiSingh-MSFT 13,516 Reputation points Microsoft Employee
    2023-03-28T05:52:28.4566667+00:00

    Hi @Gulhasan.Siddiquee ,

    Thanks for letting us know that you are working on Azure Data Studio.

    As I understood, you are getting error in renaming a column of the table.

    I have tried to create a dummy table with column name same as mentioned by you in the original question and then tried to rename it using below command and was able to do it successfully:

    
    EXEC sp_rename 'table3.[mobileappperformanceappid.app-perf-app-name]', 'mobileappperformanceappid_app-perf-app-name', 'COLUMN';
    GO
    
    
    

    User's image

    Could you please try above and let us know if it works. If not, let me know your table structure so that I may try to reproduce it. Thanks


  3. ShaktiSingh-MSFT 13,516 Reputation points Microsoft Employee
    2023-04-04T06:53:25.3433333+00:00

    Hi Gulhasan.Siddiquee •, Please find below details of the query execution of table inside schema working fine: User's image

    Try to update Azure Data Studio and execute. If not working, kindly try to create a sample table and execute commands to check if the issue is with existing table or with new too. Thank you.