Skip to main content

Posts

Showing posts from March, 2014

How to script my Securable’s in SQL Server

I ran into a situation where It required me to transfer several securable for a particular user from PROD  to a UAT environment. I was surprised to find there wasn't any easy way to do this through a GUI.   Google to the rescue and found a simple query at http://www.sqlservercentral.com/Forums/Topic1360174-391-1.aspx , Few changes were done to accommodate my needs.      SELECT DP . State_desc + ' ' + DP . permission_name +               ' ON ' + object_name ( DP . major_id ) +               ' TO ' + '[' + SU . Name   COLLATE DATABASE_DEFAULT   + ']' FROM sys . database_permissions DP JOIN sys . sysusers SU ON   SU . UID = DP . grantee_principal_id WHERE SU . Name = ' ' order by object_name ( DP . major_id )