Now: Tutorial for Web and Software Design > Database > MS SQL > Database Content
> Copy GRANT/REVOKE User/Group Permissions [Bookmark it]
Copy GRANT/REVOKE User/Group Permissions
SQL Scripts
March 6, 2006
Copy GRANT/REVOKE User/Group Permissions


>>Script Language and Platform: SQL Server 2000

This script will Copy GRANT/REVOKE User/Group Permissions.

Simply run the script with proper substitution on :
source server + source database + source user
Copy the results and paste it into Query Analyzer of:
target server + target database
RUN (:

Author: Ajith Dharwar



-------Copy GRANT/REVOKE User/Group Permissions--------------------------

--------------04/01/2005-----------------

-------------AJITH DHARWAR-----------

------------akdharwar@yahoo.com------

------------Systems Architect--------



--REPLACE <Your Role/User on Source Server> with say DBAUSER_OLD



--REPLACE <Your Role/User on Target Server> with say DBAUSER_NEW





SELECT

CASE protecttype WHEN  204 THEN 'GRANT_W_GRANT '

     WHEN 205 THEN 'GRANT '

     WHEN 206 THEN 'REVOKE '

ELSE 'DUMMY GRANT' END

+ CASE action WHEN 26 THEN 'REFERENCES'

	WHEN 178 THEN 'CREATE FUNCTION'

	WHEN 193 THEN 'SELECT'

	WHEN 195 THEN 'INSERT'

	WHEN 196 THEN 'DELETE'

	WHEN 197 THEN 'UPDATE'

	WHEN 198 THEN 'CREATE TABLE'

	WHEN 203 THEN 'CREATE DATABASE'

	WHEN 207 THEN 'CREATE VIEW'

	WHEN 222 THEN 'CREATE PROCEDURE'

	WHEN 224 THEN 'EXECUTE'

	WHEN 228 THEN 'BACKUP DATABASE'

	WHEN 233 THEN 'CREATE DEFAULT'

	WHEN 235 THEN 'BACKUP LOG'

	WHEN 236 THEN 'CREATE RULE'

 ELSE ' DUMMY ' END + ' ON ' 

+ so.name + ' TO <Your Role/User on Target Server>'

from sysprotects sp

inner join sysobjects so on (so.id=sp.id)

inner join sysusers s on (sp.uid=s.uid)

where s.name= '<Your Role/User on Source Server>'


Disclaimer: We hope that the information on these script pages is valuable to you. Your use of the information contained in these pages, however, is at your sole risk. All information on these pages is provided "as -is", without any warranty, whether express or implied, of its accuracy, completeness, or fitness for a particular purpose... Disclaimer Continued


Back to Database Journal Home

[Bookmark][Print] [Close][To Top]
  • Prev Article-Database:

  • Next Article-Database:
  • Related Materias
    No Related FoundDatabase
    Topics
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Graphic Design Tutorial
     

    Coreldraw Tutorial

      Illustrator Tutorial
      3D Graphics Articles
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial&Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial&Articles
     

    XML Style Tutorial

      AJAX Tutorial
      XML Mobile
    Flash Tutorial&Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial&Articles
     

    Linux Tutorial

      Symbian Tutorial
      MacOS Tutorial