Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Security Permission Differences Between Databases - SQL Server

RSS
Modified on Sun, Feb 01, 2009, 9:09 PM by Administrator Categorized as SQL Server
The following SQL statement will list the security permission differences between two databases.

select  
    case type
        when 'C'  then 'check constraint'
        when 'D'  then 'default'
        when 'F'  then 'foreign key'
        when 'FN' then 'function'
        when 'K'  then 'primary key'
        when 'P'  then 'stored procedure'
        when 'S'  then 'system table'
        when 'TF' then 'table function'
        when 'TR' then 'trigger'
        when 'U'  then 'user table'
        when 'V'  then 'view'
        else type
    end as type,
    odev.name
from 
    DevDb.dbo.sysobjects odev
    inner join DevDb.dbo.sysprotects pdev
        on odev.id = pdev.id
    inner join DevDb.dbo.sysusers udev
        on udev.uid = pdev.uid
where 1=1
    and udev.name = 'public'
    and pdev.protecttype in (204,205)
    and odev.name not in
        (select distinct 
            oprod.name
        from 
            ProdDb.dbo.sysobjects oprod
            inner join ProdDb.dbo.sysprotects pprod
                on oprod.id = pprod.id
            inner join ProdDb.dbo.sysusers uprod
                on uprod.uid = pprod.uid
        where 1=1
            and uprod.name = 'public'
            and pprod.protecttype in (204,205)
        )
order by 
    1,2

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2017, Patrick Jasinski.