title: How to generate a script to drop role members on all SQL Server databases?
body: <p>I'm using SQL Server 2008 R2 and SQL Server 2014...</p>
  
  <p>I'm trying to run a script to generate another script so I can execute the SQL Server's stored procedure <code>sp_droprolemember</code>. I want to run the below query on all databases:</p>
  
  <pre><code>SELECT 
      user_name([member_principal_id]) as [Username], 
      User_Name([role_principal_id]) as [Role],
      'EXEC sp_droprolemember N'''+ User_Name([role_principal_id]) +''', N''' + user_name([member_principal_id]) +''''
  FROM 
      sys.database_role_members
  WHERE 
      User_Name([role_principal_id]) = 'db_datareader'
  </code></pre>
  
  <p>I know about the <code>sp_MSforeachdb</code> but I'm having trouble to make it works with the query... (God! How I hate the T-SQL way to concatenate strings!)</p>
  
  <p>Can anyone help me with the right way to do it?</p>
  
  <p>Thank you!</p>