DBCC CLONEDATABASE is Semi-Discontinued

I saw a tweet that DBCC CLONEDATABASE was being discontinued for production databases, which both scared me and didn’t make sense. I’ve used this a few times for a quick copy of a database and like how it works. Discontinuing it seemed strange to me.

Then I read the blog post, which notes that it’s not being supported for production deployments. The post doesn’t explain why, but I’m guessing this is because all the stats and other metadata moves, and this might mess up the optimizer if different data is added. I don’t know who deploys production databases like this, but I could see people who have federated or sharded databases using this to create a new blank copy and then uploading data into it. Or maybe people who need new databases that are distributed onto remote office/edge devices used it? If you use this to create production dbs, let me know.

This command will still be used for generating schema-copies for diagnostic and troubleshooting purposes, which is what it’s there for. I assume this means Microsoft Support will support you using this to investigate strange query issues or if you create a database at their request. However, there isn’t a mention of this being used for development and test environments, which is where I use it.

Specifically, I’ve used it quite a bit lately with Redgate’s subsetter utility. I need a target that’s shaped like the source, and dbcc clonedatabase gives me that. I don’t really care about stats or anything else, I just need schema set up to move data around. It’s useful there. It’s also useful for a quick test of a deployment, where I can ensure I get the latest production schema and then run a deployment against it (hopefully using Flyway), looking for errors.

If you use this command, don’t worry. The tool isn’t going away, and the restriction against production copies doesn’t take place until March 1, 2025. That’s nearly a year from now to change your process. If you’ve never used it, well, I don’t have a good reason to start using it, but you ought to be aware of how it works. Learning about new features is handy, as you might discover a problem the knowledge can solve. However, if you don’t know it exists, it will never enter your mind as a solution.

Be curious and try things. It’s easy, and it’s fun.

Steve Jones

Listen to the podcast at Libsyn, Spotify, or iTunes.

Note, podcasts are only available for a limited time online.

About way0utwest

Editor, SQLServerCentral
This entry was posted in Editorial and tagged . Bookmark the permalink.

2 Responses to DBCC CLONEDATABASE is Semi-Discontinued

  1. Eitan Blumin says:

    This deprecation is indeed rather peculiar. If the issue is with stats and data-dependent metadata then shouldn’t that not be an issue if CLONEDATABASE is used without cloning the statistics?

    One of our customers has a use case of using this in production for quickly creating tenant databases in a multi-tenant environment. It’s so much faster and easier than running a DacPac deployment.

    Like

    • way0utwest says:

      That’s the exact use case they are deprecating. I wonder why as well. I’d think if you used DBCC CLONEDATABASE and then UPDATE STATS for everything, this wouldn’t be an issue

      Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.