Note
This document is applicable only to instances of SQL Server 2012 and later versions. For information about how to copy a database for SQL Server 2008 R2, see Copy a database for SQL Server 2008 R2.

To clone a database using SQL commands, specify the source and target databases in the stored procedure sp_rds_copy_database. The cloning duration varies with the database size.

Prerequisite

Before cloning a database, make sure that the available space of the instance is at least 1.3 times the size of the cloned database.

Procedure

Run the following commands to clone a database:

USE master
GO
--database engine edtion
SELECT SERVERPROPERTY('edition')
GO
--create database
CREATE DATABASE testdb

GO
EXEC sp_rds_copy_database 'testdb','testdb_copy'

SELECT *
FROM sys.databases
WHERE name IN ('testdb','testdb_copy')

SELECT 
    family_guid,database_guid,* 
FROM sys.database_recovery_status
WHERE 
DB_NAME(database_id) IN ('testdb','testdb_copy')