title: Detach database programmatically
body: <p>I have a database "D:\MDF CONNECTION SAMPLE\BIN\DEBUG\HARMDATABASE.MDF".
  I am trying to detach or rename it, with this code:</p>
  
  <pre><code>SqlConnection conn = new SqlConnection("Data Source=.\\MSSQLSERVER2008;database=Master;Integrated Security=True;");
  SqlCommand cmd = new SqlCommand("", conn);
  cmd.CommandText = @"sys.sp_detach_db D:\MDF CONNECTION SAMPLE\BIN\DEBUG\HARMDATABASE.MDF";
  conn.Open(); 
  cmd.ExecuteNonQuery();
  cmd.Dispose();
  conn.Dispose();
  </code></pre>
  
  <p>But getting an error:</p>
  
  <blockquote>
    <p>Incorrect syntax near '\'.</p>
  </blockquote>