title: SQL Server 2005 Logins, Securables, Roles and Permissions Backup
body: <p>Our non production servers have information refreshed into them on a regular basis from production.  The way this is done is to do a full backup of production, then restore it onto the non-production SQL Server. This has the undesired effect of overwriting all of the permissions for users.  </p>
  
  <p>I have been trying to find a method to pull those permissions out of the database in the form of a script. That way when the database is refreshed, I can run the script against the newly refreshed database and restore the permissions.</p>
  
  <p>I tried to find the data in sys.database_principals and sys.database_permissions, but my SQL-fu isn't good enough to make this data into something usable.</p>
  
  <p>What's the best method to get this data out?</p>