title: T-SQL - How can I copy a database and keep security settings intact?
body: <p>I have a SQL 2005 Express database with security configured for Windows authentication on my development machine. Occasionally I need to copy it to a SQL 2008 R2 test server that uses SQL authentication. I've tried detaching and attaching the development copy on the test server, as well as restoring a development backup on the test server, but in both cases the SQL account's role membership and permissions that I had configured previously are lost and I have to reconfigure them.</p>
  
  <p>Is there a way to copy the database to the test server and keep the existing SQL user security configuration intact after restore/attach?</p>
  
  <p>Thanks!</p>