Copy a Azure SQL DB with just the objects and no data

Swathi Sudheer 1 Reputation point
2023-09-26T14:46:23.4266667+00:00

Hi,

How can we copy the objects of an Azure SQL Database from one tenant to another tenant without copying the data, just the structure?

I was able to copy the database following this copy-to-a-different-subscription documentation from Microsoft using SQL scripts. But this doesn't talk about how we can copy the database without the data.

Does anybody have any suggestion?

Azure SQL Database
Azure
Azure
A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.
1,408 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Alberto Morillo 34,671 Reputation points MVP Volunteer Moderator
    2023-09-26T15:26:50.56+00:00

    You can create a dacpac (containing only the database schema) of the existing database using SqlPackage and then just import it into an Azure SQL logical server that exist on the other tenant.

    sqlpackage.exe /Action:Export /ssn:tcp:{SERVERNAME}.database.windows.net,1433 /sdn:{DBNAME} /su:*** /sp:*** /tf:C:\temp\{DBNAME}.bacpac
    
    
    

    Here you will find more information about the export action of the SqlPackage tool.

    0 comments No comments

  2. RahulRandive 10,486 Reputation points Volunteer Moderator
    2023-09-26T16:11:27.0233333+00:00

    Hi @Swathi Sudheer

    How about Generate Scripts wizard for scripts of all database objects.

    SSMS >Right click the database > Tasks > Generate Scripts. During the process, please choose script Schema only option as below screenshot.

    User's image

    Here is a blog for reference Methods to script SQL Server database objects

    Another reference document- https://www.mssqltips.com/sqlservertip/4664/copy-a-sql-server-database-with-just-the-objects-and-no-data/

    Thank you!


Your answer

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