“Ubah Skema di SQL Server” Kode Jawaban

SQL Server mengubah skema tabel

-- change schema from [dbo] to [exe]
IF (NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'exe')) 
BEGIN
    EXEC ('CREATE SCHEMA [exe] AUTHORIZATION [dbo]')
END

ALTER SCHEMA exe 
    TRANSFER dbo.Employees
Inquisitive Ibex

ubah skema sql server

ALTER SCHEMA exe 
    TRANSFER dbo.Employees
Munnam Yousuf

Ubah Skema di SQL Server

declare @sql varchar(8000), @table varchar(1000), @oldschema varchar(1000), @newschema   varchar(1000)

  set @oldschema = 'dbo'
  set @newschema = 'exe'

 while exists(select * from sys.tables where schema_name(schema_id) = @oldschema)

  begin
      select @table = name from sys.tables 
      where object_id in(select min(object_id) from sys.tables where  schema_name(schema_id)  = @oldschema)

    set @sql = 'alter schema ' + @newschema + ' transfer [' + @oldschema + '].' + @table

   exec(@sql)
 end
mohammad ghari

ubah skema sql server

IF (NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'exe')) 
BEGIN
    EXEC ('CREATE SCHEMA [exe] AUTHORIZATION [dbo]')
END
Munnam Yousuf

Jawaban yang mirip dengan “Ubah Skema di SQL Server”

Pertanyaan yang mirip dengan “Ubah Skema di SQL Server”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya