title: How to make a copy of a database in SQL Server
body: <p>I can't seem to find any SQL that will clone one database in SQL Server within the same server.</p>
  
  <p>Let's say I have a database called <code>MyDB</code>. I simply want to make a copy of <code>MyDB</code> to <code>MyDb2</code>. I thought that this would work:</p>
  
  <pre><code>BACKUP DATABASE MyDB TO MyDB2;
  </code></pre>
  
  <p>But I get this error when I try to execute it:</p>
  
  <blockquote>
    <p>Backup device 'DbTestBack' does not exist. To view existing backup devices, use the sys.backup_devices catalog view. To create a new backup device use either sp_addumpdevice or SQL Server Management Studio.</p>
  </blockquote>
  
  <p>Does anyone know what the best way to do this is? I want an exact duplicate of the original including security permissions.</p>