Copy database script in Azure Managed Instance connection

Sayali Khot (skhot) 20 Reputation points
2024-02-22T05:27:25.2+00:00

Hi Team,   We are providing support for Azure Managed Instance in our application. We want to create database from existing database. 
Can you please help us providing the query for the same?
ex, For Azure SQL server authentication, we are using below script to create database from existing database,
"CREATE DATABASE DemoDB AS COPY OF SampleDB"
We need similar behavior in Azure Managed Instance.

Azure SQL Database
{count} votes

3 answers

Sort by: Most helpful
  1. SSingh-MSFT 16,461 Reputation points Moderator
    2024-02-22T09:27:37.98+00:00

    Hi Sayali Khot (skhot),

    Welcome to Microsoft Q&A forum.

    As I understand, you want to Copy Database in Azure Managed Instance.

    This could be done through 3 methods: Azure Portal, PowerShell and CLI as illustrated in the below link:

    https://learn.microsoft.com/en-us/azure/azure-sql/managed-instance/database-copy-move-how-to?view=azuresql&tabs=azure-portal#copy-or-move-database

    As per the existing documentation, you can perform copies of Azure SQL Single and Pooled Databases only by COPY command https://learn.microsoft.com/en-us/sql/t-sql/statements/create-database-transact-sql?view=azuresqldb-current&preserve-view=true&tabs=sqlpool#database-copies

    Refer to https://learn.microsoft.com/en-us/sql/t-sql/statements/create-database-transact-sql?view=azuresqldb-mi-current&preserve-view=true&tabs=sqlpool for Azure SQL Managed Instance.

    Let us know if above information helped or you have a different ask.

    Thanks

    0 comments No comments

  2. RahulRandive 10,501 Reputation points Volunteer Moderator
    2024-02-22T16:08:11.3633333+00:00

    Hi @Sayali Khot (skhot)
    It seems you're looking for a T-SQL command to copy a database in Azure Managed Instance, similar to what's available in Azure SQL Server. However, based on the documentation, currently, you can copy the database in SQL Managed Instance only using the Portal, PowerShell, or CLI. User's image

    https://learn.microsoft.com/en-us/azure/azure-sql/managed-instance/database-copy-move-how-to?view=azuresql&tabs=azure-portal#copy-or-move-database Thank you!

    0 comments No comments

  3. SSingh-MSFT 16,461 Reputation points Moderator
    2024-02-23T03:52:34.3433333+00:00

    Hi Sayali Khot (skhot),

    Thanks for your patience.

    I have checked with the internal team and Copy of Azure SQL Managed Instance could only performed by Azure Portal, CLI and Powershell.

    It is not supported via TSQL.

    However, if you feel this feature should be added and if it is feasible then I would suggest you to raise your Feedback over Azure SQL Database Community Feedback Channel where concerned team looks into the requests on the basis of importance and up-votes.

    Hope this helps. Let us know if you have further queries. Thanks

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.