title: Convert a MS SQL 2008 .mdf file to .bak file
body: <p>I try to convert a .mdf file to a .bak file, I have been reading this guide: <a href="http://forums.asp.net/p/1448416/3870094.aspx" rel="nofollow">http://forums.asp.net/p/1448416/3870094.aspx</a></p>
  
  <pre><code>BACKUP DATABASE [NameOfDatabase] TO DISK = N'D:\path\filename.bak' WITH NOFORMAT, NOINIT, NAME = N'NameOfDatabase-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10
  </code></pre>
  
  <p>Replace NameOfDatabase with.... name of your database.</p>
  
  <p>Replace D:\path\filename.bak with place you want to backup with</p>
  
  <p>Replace Name = N database name for cosmetic indexing reasons...</p>
  
  <p>But I get an error message when I run it.</p>
  
  <p>In Visual Studio 2010 in Server Explorer I select Data Connection/myDatabase.mdf and rightclick Stored Procedure and choose "add new stored Procedure". There I write:</p>
  
  <pre><code>BACKUP DATABASE [myDatabase] TO DISK = N'C:\db\dbCopy.bak' WITH NOFORMAT, NOINIT, NAME = N'dbCopy-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10
  </code></pre>
  
  <p>When I select the text and run selection I get this error message:</p>
  
  <p>Executing selected script from mssql:://Home\e1d5110c-dd6f-4d/C:\USERS\myHome\DESKTOP\myPage\APP_DATA\MYDATABASE.MDF/dbo/Stored Procedure/dbo/StoredProcedure1</p>
  
  <pre><code>Database 'myDatabase' does not exist. Make sure that the name is entered correctly.
  BACKUP DATABASE is terminating abnormally.
  No rows affected.
  (0 row(s) returned)
  </code></pre>
  
  <p>What am I doing wrong? If I change 'myDatabase' to 'C:\USERS\myHome\DESKTOP\myPage\APP_DATA\MYDATABASE.MDF' I get this message:</p>
  
  <pre><code>Database 'C:\USERS\myHome\DESKTOP\myPage\APP_DATA\MYDATABASE.MDF' does not exist. Make sure that the name is entered correctly.
  BACKUP DATABASE is terminating abnormally.
  No rows affected.
  (0 row(s) returned)
  </code></pre>