SQL SERVER – CLONEDATABASE: Generate Statistics and Schema Only Copy of the Database

CLONEDATABASE can Generate Statistics and schema-only diagnostic copies without copying table rows. I use that distinction when investigating optimizer behavior.

A diagnostic cabinet preserves empty molds while the finished vessels remain in the source cabinet.

I noticed this feature while reviewing SQL Server 2016 enhancements. It also appeared in SQL Server 2014 SP2. The useful distinction is what travels with the copy: metadata and statistics, rather than the business data.

-- Diagnostic example only. Use a new destination name.
DBCC CLONEDATABASE (N'AS_Sample', N'My_Sample_mybkp');

SELECT DATABASEPROPERTYEX(N'My_Sample_mybkp', N'IsClone') AS is_clone,
       DATABASEPROPERTYEX(N'My_Sample_mybkp', N'Updateability') AS updateability;

The source must exist and the destination must not. Review the supported objects and options for your build before creating a clone. Use it for diagnosis, not as the starting point for a production database.

Historical SSMS output for AS_Sample and My_Sample_mybkp. The messages identify the clone as diagnostic, not production, material.
Historical SSMS output for AS_Sample and My_Sample_mybkp. The messages identify the clone as diagnostic, not production, material.
Historical Object Explorer shows My_Sample_mybkp marked Read-Only.
Historical Object Explorer shows My_Sample_mybkp marked Read-Only.

The original size comparison

My historical source data files were close to 600 MB. The clone was about 16 MB. Those sizes belonged to that instance. They aren’t expected sizes for every database.

Historical properties dialogs compare the original source and clone file sizes.
Historical properties dialogs compare the original source and clone file sizes.

Verify the clone

IsClone = 1 identifies a clone. A NULL result needs a check of the name, access and property applicability. The current lab uses a different database name from the historical sample.

SSMS result showing the test database is online, read only, a clone, and verified

The separately named AdventureWorks2025 test clone is online, read-only and verified. Use its name when checking the pictured properties. It isn’t the same database as the historical size comparison.

A diagnostic clone is not a data backup, it is a schema-and-statistics copy with a limited purpose.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.


Discover more from SQL Authority with Pinal Dave

Subscribe to get the latest posts sent to your email.

Schema, SQL Scripts, SQL Server, SQL Server 2016, SQL Statistics
Previous Post
Linked Servers and What Goes Wrong With Them
Next Post
SQL SERVER – TDE Effects on TempDB’s Slow Performance

Related Posts

2 Comments. Leave new

  • Hello Pinal,

    Fabulous post, as always !

    It could be very helpful during performance tuning exercise when Production data is either too critical to be shared or matching resources to proceed with Prod DB restore are not available. It is simpler than generating database scripts with few custom configurations including setting ‘script statistics’ option to script statistics and histogram. Not 100% sure if outcome is exactly same for both approaches.

    Appreciate your great contribution to SQL community.

    Br,
    Anil

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.