Changing a table owner

前端 未结 5 1311
名媛妹妹
名媛妹妹 2021-02-04 00:21

I\'m trying to change the owner of a table:

sp_changeobjectowner \'OWNER.TABLENAME\', \'dbo\'

But when executing I get the error message:

5条回答
  •  無奈伤痛
    2021-02-04 01:07

    If dropping the table is an option, you can drop and recreate under the desired user. Just specify dbo in the create script. For example:

    USE [X]
    GO
    
    /****** Object:  Table [dbo].[TableName]    Script Date: 4/21/2014 1:26:37 PM ******/
    
    CREATE TABLE [dbo].[TableName](
        [Field1] [bigint] NOT NULL,
        [Field2] [nvarchar](50) NOT NULL,
        [Field3] [datetime] NOT NULL
    ) ON [PRIMARY]
    
    GO
    

提交回复
热议问题