Microsoft Certified IT Professional Rudi Bruchez EI Microsoft Certified IT Professional

Rudi Bruchez EI · www.pachadata.com · rudi@pachadata.com · +33 6 22 48 76 99
Consulting, audit, performance tuning, solutions, training
SQL Server OLTP and BI / NoSQL

Version of November 30, 2026 (d3a32c4e) · https://www.pachadata.com/en/services/client-instructions/database-clone/

Sending a database clone with no data

Use DBCC CLONEDATABASE to make a copy of a SQL Server database with no data, with its Query Store, for a performance analysis.

DBCC CLONEDATABASE creates a copy of a database that holds its schema, the statistics and the Query Store (query text, execution plans, runtime statistics), without any data. It is what will let me analyze the query history of a database without seeing its contents. With it, I have everything I need for a first performance analysis pass on the database.

Creating the clone

Run this as a member of the sysadmin role, on the instance that hosts the database. The example uses the PachaDataFormation database: replace its name with yours, in both places, and keep the _Clone suffix for the clone.

USE master;

-- Write to disk the Query Store statistics still held in memory
EXEC PachaDataFormation.sys.sp_query_store_flush_db;

-- Clone with no data, backed up in one go
DBCC CLONEDATABASE (PachaDataFormation, PachaDataFormation_Clone)
WITH BACKUP_CLONEDB;

The command creates the PachaDataFormation_Clone database on the instance, backs it up to the instance’s default backup directory and verifies the backup. The last message gives the file name:

Clone backup succeeded and is stored in 'PachaDataFormation_Clone_807744542.bak'.

Once the backup is written, drop the clone from the instance: Microsoft does not support a clone used in production.

DROP DATABASE PachaDataFormation_Clone;

The .bak file is what I need. It holds no table rows and is usually a few tens of megabytes.

You can also zip it to save a little space.

What the clone contains

ContentIn the clone
Table rowsno
Schema (tables, indexes, procedures, views)yes
Query Store: query text, plans, runtime statisticsyes
Statistics, histograms includedyes

Statistics are what the optimizer reads to estimate row counts: without them, the plans cannot be reproduced on the clone. A histogram holds up to 200 real values from the column it describes.

The Query Store text and plans can also hold values: literals written into the queries and the parameter values at compile time.

The clone holds only what the Query Store holds when the clone is made. The Query Store keeps 30 days of history by default, less if it reaches its maximum size.

Further reading

Contact

I have been an independent SQL Server consultant since 2006. I help when an application slows down, when a server costs too much in storage or licenses, or when a migration must not stop production: audit and diagnosis, query and index tuning, migrations, high availability, training. On site, or as a remote audit delivered in five working days.

rudi@pachadata.com · +33 6 22 48 76 99 · www.pachadata.com/en/contact/