Change Schema Name Of Table In SQL

后端 未结 10 2247
清歌不尽
清歌不尽 2020-12-04 06:15

I want to change schema name of table Employees in Database. In the current table Employees database schema name is dbo I want to chan

相关标签:
10条回答
  • 2020-12-04 06:55

    Your Code is:

    FROM
     dbo.Employees
    TO
     exe.Employees
    

    I tried with this query.

    ALTER SCHEMA exe TRANSFER dbo.Employees
    

    Just write create schema exe and execute it

    0 讨论(0)
  • 2020-12-04 06:59

    In case, someone looking for lower version -

    For SQL Server 2000:

    sp_changeobjectowner @objname = 'dbo.Employess' , @newowner ='exe'

    0 讨论(0)
  • 2020-12-04 07:00

    Through SSMS, I created a new schema by:

    • Clicking the Security folder in the Object Explorer within my server,
    • right clicked Schemas
    • Selected "New Schema..."
    • Named my new schema (exe in your case)
    • Hit OK

    I found this post to change the schema, but was also getting the same permissions error when trying to change to the new schema. I have several databases listed in my SSMS, so I just tried specifying the database and it worked:

    USE (yourservername)  
    ALTER SCHEMA exe TRANSFER dbo.Employees 
    
    0 讨论(0)
  • 2020-12-04 07:02
    CREATE SCHEMA exe AUTHORIZATION [dbo]
    GO
    
    ALTER SCHEMA exe
    TRANSFER dbo.Employees
    GO
    
    0 讨论(0)
提交回复
热议问题