Rename table name and column name using sql query

Total Post:183


 1852  View(s)
Rate this:
I have a table with the MyTable name and its columns name is
1. sr
2. Name
and i want to rename MyTable into empTable and Name column rename into empName.

MyTable structure as below

Create table MyTable
   Name varchar(100)

can any one help me?

Thank in advance
  1. Re: Rename table name and column name using sql query

    Hi Ankita Pandey

    You can use this code
    I'm renaming your table and cloumn name with the storeprocedure sp_Rename

    sp_Rename 'MyTable', 'empTable'

    Now your table name is empTable after renaming your table and now i am going to rename the Name column into empName.
    sp_Rename 'empTable.Name', 'empName'
    and now you can see your table

    Now verify your table

    select * from empTable

    I hope this resolve your problem


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.