0

I have a bacpac file which I generated from SQL Server. And now, I am restoring the database using this bacpac file into the Azure Managed Instance.

Here, I am trying to change the schema of the table according to the requirement. The question is, can I change the schema of tables while restoring the database into Azure Managed Instance?

For instance, I have 10 tables having the schema sales and I want to change the schema to currentSales.

Robin
  • 1

1 Answers1

1

I know of no way to automate it as part of the bacpac process but if you truly only have a few Tables then you can script out a schema TRANSFER for each of them like so:

ALTER SCHEMA currentSales TRANSFER sales.Table1;
ALTER SCHEMA currentSales TRANSFER sales.Table2;
ALTER SCHEMA currentSales TRANSFER sales.Table3;
ALTER SCHEMA currentSales TRANSFER sales.Table4;
ALTER SCHEMA currentSales TRANSFER sales.Table5;
ALTER SCHEMA currentSales TRANSFER sales.Table6;
ALTER SCHEMA currentSales TRANSFER sales.Table7;
ALTER SCHEMA currentSales TRANSFER sales.Table8;
ALTER SCHEMA currentSales TRANSFER sales.Table9;
ALTER SCHEMA currentSales TRANSFER sales.Table10;

Please keep in mind this transfers those Tables only and does not update any references to those Tables inside other database objects such as Views or Stored Procedures. Those would need to be manually altered, if you are using any that reference these procedures.

J.D.
  • 40,776
  • 12
  • 62
  • 141