title: How to restore a SQL Server backup to another database?
body: <p>I want to restore a database to 12/29/2016. I want to restore to another name so I do not lose the state of the original database. The name of my database is APDatabase.  </p>
  
  <p>How do I modify the SQL below to restore to a database called <code>TempAPDatabase</code>?  I also want to be careful not to lose any of the backup information which is stored on the disk as 87A991B1-9305-45C1-A461-9B1A3174A707.</p>
  
  <pre><code>USE [master]
  
  BACKUP LOG [APDatabase] 
  TO DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL12.MYSQLSERVER\MSSQL\Backup\APDatabase_LogBackup_2017-03-13_10-52-54.bak' 
  WITH NOFORMAT, NOINIT,  
       NAME = N'APDatabase_LogBackup_2017-03-13_10-52-54', 
       NOSKIP, NOREWIND, NOUNLOAD,  NORECOVERY, STATS = 5
  
  RESTORE DATABASE [APDatabase] 
  FROM DISK = N'{87A991B1-9305-45C1-A461-9B1A3174A707}10' 
  WITH FILE = 1, NORECOVERY, NOUNLOAD, STATS = 5
  
  RESTORE LOG [APDatabase] 
  FROM DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL12.MYSQLSERVER\MSSQL\Backup\APDatabase_LogBackup_2017-03-10_06-47-10.bak' 
  WITH FILE = 1, NOUNLOAD, STATS = 5, STOPAT = N'2016-12-29T00:00:00'
  GO
  </code></pre>