Cari Blog Ini

02 Juli 2012

How To Check All User in Database

-------------------------------------------------------------------
-----code:start
-------------------------------------------------------------------
select
    cast(CATALOG_NAME as varchar(35)) as CATALOG_NAME,
    cast(SCHEMA_NAME as varchar(30)) as SCHEMA_NAME,
    cast(SCHEMA_OWNER as varchar(30)) as SCHEMA_OWNER
from INFORMATION_SCHEMA.SCHEMATA
order by CATALOG_NAME
-------------------------------------------------------------------
-----code:end
-------------------------------------------------------------------


Example Result Messages:
CATALOG_NAME                 SCHEMA_NAME                    SCHEMA_OWNER                  
---------------------------- ------------------------------ ------------------------------
HRD                                     dbo                            dbo
master                                  dbo                            dbo
model                                   dbo                            dbo
msdb                                    dbo                            dbo
Northwind                           dbo                            dbo
pubs                                    dbo                            dbo
ReportServer                       dbo                            dbo
ReportServerTempDB           dbo                            dbo
tempdb                                  dbo                            dbo

(9 row(s) affected)