title: Failed to Restore bak files to SqlServer with error 'There is insufficient free space on disk volume ...', there's enough space on it
body: <p>Here is the situation.</p>
  
  <p>I have a Database DB1 on SQL server Server1.</p>
  
  <p>I backup DB1 to db1.bak, and then I try to restore DB1.bak back to Server1 with a different name DB2.</p>
  
  <p>I'm using C# to do this job, but it fails. Restoring will be successfully if I don't resotre DB1.bak back to the same sql-server with a different name and with the orignal database exists. </p>
  
  <p>I can also restore successfully using Microsoft SQL Server Management Studio.
  Here is the SQL generated from my C# program.</p>
  
  <pre><code>SET @RestoreSQL = '
  RESTORE DATABASE [DB2] FROM  DISK = N''e:\Temp\DB1.bak'' WITH  FILE = 1, 
  MOVE N''CtrlSys'' TO N''E:\Program Files\Microsoft SQL Server\MSSQL11.LATIN1_2012\MSSQL\DATA\DB2Sys.mdf'',
  MOVE N''CtrlData'' TO N''E:\Program Files\Microsoft SQL Server\MSSQL11.LATIN1_2012\MSSQL\DATA\DB2Data.ndf'',
  MOVE N''CtrlIx'' TO N''E:\Program Files\Microsoft SQL Server\MSSQL11.LATIN1_2012\MSSQL\DATA\DB2Ix.ndf'',
  MOVE N''CtrlLog'' TO N''E:\Program Files\Microsoft SQL Server\MSSQL11.LATIN1_2012\MSSQL\DATA\DB2Log.ldf'',
  NOUNLOAD,  REPLACE,  STATS = 10'
  exec (@RestoreSQL)
  </code></pre>
  
  <p>Here is the error:</p>
  
  <pre><code>Msg 3257, Level 16, State 1, Line 2
  There is insufficient free space on disk volume 'E:\' to create the database. 
  
  The database requires 86240788480 additional free bytes, while only 83155132416 bytes are available.
  
  Msg 3119, Level 16, State 4, Line 2
  
  Problems were identified while planning for the RESTORE statement. Previous messages  provide details.
  
  Msg 3013, Level 16, State 1, Line 2
  
  RESTORE DATABASE is terminating abnormally
  </code></pre>