1;M;Tables within Database;Select distinct b.name,b.uid from dbo.sysobjects a, dbo.sysusers b where a.type = 'U' and a.uid=b.uid order by 1;Owner;1200;Id;1;
3;M;Views within Database;Select distinct b.name,b.uid from dbo.sysobjects a, dbo.sysusers b where a.type='V' and a.uid=b.uid order by 1;Owner;1200;Id;1;
4;M;System Tables within Database;Select distinct b.name,b.uid from dbo.sysobjects a, dbo.sysusers b where a.type = 'S' and a.uid=b.uid order by 1;Owner;1200;Id;1;
5;M;Triggers within Database;Select distinct b.name, b.uid from dbo.sysobjects a, dbo.sysusers b where a.type='TR' and a.uid=b.uid order by 1;Owner;1200;Id;1;
6;M;Defaults within Database;Select distinct b.name,b.uid from dbo.sysobjects a, dbo.sysusers b where a.type = 'D' and a.uid=b.uid order by 1;Owner;1200;Id;1;
7;U;Users/roles within database;Select name, case when issqlrole=1 then 'System Role' when isapprole=1 then 'App Role' else 'User' end,uid from dbo.sysusers order by 1;Id;2200;Type;1800;Id;1;
8;M;Rules within Database;Select distinct b.name, b.uid from dbo.sysobjects a, dbo.sysusers b where a.type = 'R' and a.uid=b.uid order by 1;Owner;1200;Id;1;
9;M;Procedures within Database;Select distinct b.name, b.uid from dbo.sysobjects a, dbo.sysusers b where a.type in ('P','X') and a.uid=b.uid order by 1;Owner;1200;Id;1;
10;U;Users within database;Select name,uid from dbo.sysusers where issqlrole=0 and isapprole=0 order by 1;User;2500;Id;1;
11;M1;Tables within Owner;Select a.name, id from dbo.sysobjects a where a.type ='U' and a.uid=? order by 1;Table;2145;Id;1;
12;M1;Views within Owner;Select a.name, id from dbo.sysobjects a where a.type = 'V' and a.uid=? order by 1;Table;3000;Id;1;
13;U;Roles within database;Select name,uid from dbo.sysusers where issqlrole=1 or isapprole=1 order by 1;Role;2500;Id;1;
14;M1;Triggers within Owner;Select name, id from dbo.sysobjects a where type='TR' and uid=? order by 1;Table;3000;Id;1;
15;M1;Logons for user;Select a.loginname,b.name ,a.dbname,a.suid from master.dbo.syslogins a left outer join dbo.sysusers b on a.suid=b.suid;Login name;1000;User name in this db;1600;Default database ;1455;Id;1;
16;M;Users/Groups within Database;Select name from dbo.sysusers order by 1;User Name;1200;Group?;800;
17;M1;Procedures within Owner;Select name, type,id from dbo.sysobjects a where type in ('P','X') and uid=? order by 1;Procedure;2500;Type;500;Id;1;
18;M1;Rules within Owner;Select name,id from dbo.sysobjects a where type = 'R' and uid=? order by 1;Rule;3000;Id;1;
19;M1;Defaults within Owner;Select a.name, id from dbo.sysobjects a where a.type ='D' and a.uid=? order by 1;Default;3000;Id;1;
20;M1;Defaults within Owner;Select a.name, id from dbo.sysobjects a where a.type ='D' and a.uid=? order by 1;Default;2000;Id;1000;
21;M1;Access list for;Select user_name(uid), (case action when 193 then 'SELECT' when 195 then 'INSERT' when 196 then 'DELETE' when 197 then 'UPDATE' when 26 then 'REFERENCES' when 224 then 'EXECUTE' end), case protecttype when 204 then 'YES' when 205 then 'NO' when 206 then 'REV' else convert(char,protecttype) end, uid from dbo.sysprotects where id=? ;User;1500;Privilege;1500;Grantable?;1000;Id;1;
22;C1;Column list for;Select c.name, t2.name, c.length, c.scale, case c.status & 8 when 8 then 'Y' else 'N' end, case when t.name<>t2.name then t.name else '' end from dbo.syscolumns c, dbo.systypes t, dbo.systypes t2 where c.usertype=t.usertype and c.id =? and t.type=t2.type and t2.usertype=(select min(usertype) from dbo.systypes where type=t2.type and usertype>0) order by c.colid,t2.name;Name;2000;Type;1000;Length;600;Scale;500;Nulls;500;User Type;2000;
23;S1;Full detail of;Select * from dbo.sysobjects where id=?;Column;1500;Value;3000;
24;M1;Referenced Tables for;Select u.name, o.name, object_name(r.constid), col_name(fkeyid,fkey1)+' '+coalesce(col_name(fkeyid,fkey2),'')+' '+coalesce(col_name(fkeyid,fkey3),'')+' '+coalesce(col_name(fkeyid,fkey4),''), col_name(rkeyid,rkey1)+' '+coalesce(col_name(rkeyid,rkey2),'')+' '+coalesce(col_name(rkeyid,rkey3),'')+' '+coalesce(col_name(rkeyid,rkey4),''),o.id from dbo.sysreferences r, dbo.sysobjects o, dbo.sysusers u where r.rkeyid=o.id and o.uid=u.uid and r.fkeyid=?;Owner;1500;Referenced Table;1800;Constraint;1000;Cols (FK);1500;PK in Ref Tab;1500;Id;1;
25;M1;Column Default values for ;Select a.name,c.text, object_name(c.id),c.id from dbo.syscolumns a, dbo.syscomments c where a.cdefault=c.id and c.texttype=2 and c.colid=1 and a.id=?;Column;2000;Default Value;4000;Default Name;1500;Id;1;
26;X1;Text of ;Select text from dbo.syscomments where id=? and texttype=2 order by colid;Text;4800;
27;X1;Text of ;Select text from dbo.syscomments where id=? and texttype=2 order by colid;Text;6225;
28;X1;Text of Procedure;Select text from dbo.syscomments where id=? and texttype=2 order by number,colid;Procedure Text;4245;
29;V1;Text of View;Select text from dbo.syscomments where id=? and texttype=2 order by colid;View Text;2505;
30;W1;Text of View;Select text from dbo.syscomments where id=? and texttype=2 order by colid;View Text;5430;
31;M1;Triggers on Table;Select user_name(b.uid), b.name, (case when b.id=a.deltrig then 'Delete' when b.id=a.updtrig then 'Update' when b.id=a.instrig then 'Insert' end ), b.id from dbo.sysobjects a, dbo.sysobjects b where (b.id = a.deltrig or b.id = a.updtrig or b.id=a.instrig) and a.id=?;Owner;1500;Trigger Name;2000;Event;800;Id;1;
32;M1;Tables within Owner;Select a.name,id from dbo.sysobjects a where a.type ='U' and a.uid=? order by 1;Table;2000;Id;1000;
33;M1;Views within Owner;Select a.name,id from dbo.sysobjects a where a.type = 'V' and a.uid=? order by 1;Table;2000;Id;1000;
34;D;Contents of;unused;Name;1500;
35;X;Definition of Constraint;Select text from dbo.syscomments where id = (select id from dbo.sysobjects a, dbo.sysusers b where a.uid=b.uid and b.name='?' and a.name='?') and texttype=2 order by colid;Constraint Definition;6360;
36;M1;Triggers within Owner;Select name, id from dbo.sysobjects a where type='TR' and uid=? order by 1;Trigger;2000;Id;1000;
37;M1;System Tables within Owner;Select name,id from dbo.sysobjects c where type = 'S' and uid =? order by 1;Table;3000;Id;1;
38;M;Triggers within Owner;Select name, id,id from dbo.sysobjects a where type='TR' and uid=? order by 1;Table;1200;Desc;2000;
39;S2;Full details of;Select * from dbo.sysindexes where id=? and indid=?;Column;1200;Value;3000;
40;M1;System Tables within Owner;Select name, id from dbo.sysobjects where type = 'S' and uid =? order by 1;Table;2000;Id;1000;
41;M2;Columns in index;Select keysl, keys2 from dbo.sysindexes where id=? and indid=?;Keys1;1200;Keys2;1200;
42;M1;Dependent Tables for;Select u.name, o.name, object_name(r.constid), col_name(rkeyid,rkey1)+' '+coalesce(col_name(rkeyid,rkey2),'')+' '+coalesce(col_name(rkeyid,rkey2),'')+' '+coalesce(col_name(rkeyid,rkey2),''), col_name(fkeyid,fkey1)+' '+coalesce(col_name(fkeyid,fkey2),'')+' '+coalesce(col_name(fkeyid,fkey2),'')+' '+coalesce(col_name(fkeyid,fkey2),''),o.id from dbo.sysreferences r, dbo.sysobjects o, dbo.sysusers u where r.fkeyid=o.id and o.uid=u.uid and r.rkeyid=?;Owner;1500;Dependent Table;1800;Constraint;1000;Cols (PK);1500;FK in Dep Tab;1500;Id;1;
43;M1;Parameters for;Select c.name, t2.name, c.length, c.scale, case c.status & 8 when 8 then 'Y' else 'N' end, case c.status&0x40 when 0 then 'IN' else 'OUT' end, case c.number when 0 then '' else convert(char,c.number) end from dbo.syscolumns c, dbo.systypes t, dbo.systypes t2 where c.usertype=t.usertype and c.id =? and t.type=t2.type and t2.usertype=(select min(usertype) from dbo.systypes where type=t2.type and usertype>0) order by c.colid,t2.name;Name;1110;Type;645;Length;600;Scale;525;Nulls;450;Usage;600;Proc Section;1095;
44;M1;Rules within Owner;Select name, id from dbo.sysobjects a where type = 'R' and uid=? order by 1;Rule;2000;Id;1000;
45;M1;Procedures within Owner;Select name, type,id from dbo.sysobjects a where type in ('P','X') and uid=? order by 1;Procedure;2000;Type;400;Id;1000;
46;S1;Full detail of;Select * from master.dbo.syslogins where suid=?;Column;1500;Value;3000;
47;M1;Login user;Select b.name, a.dbname, b.uid from master.dbo.syslogins a left outer join dbo.sysusers b on a.suid=b.suid where a.suid=?;User name;1500;Default Database;1500;id;1;
48;X2;Text of Section;Select text from dbo.syscomments where id=? and number=? and texttype=2 order by colid;Section Text;6135;
49;B1;Table authorities for;Select user_name(o.uid),o.name, (case action when 193 then 'SELECT' when 195 then 'INSERT' when 196 then 'DELETE' when 197 then 'UPDATE' when 26 then 'REFERENCES' when 224 then 'EXECUTE' end), case protecttype when 204 then 'YES' when 205 then 'NO' when 206 then 'REV' end, user_name(p.grantor), p.id from dbo.sysprotects p, dbo.sysobjects o where p.uid=? and p.id=o.id and o.type in ('S','U','V') order by 1,2,3;Owner;1500;Name;1800;Privilege;1000;Grantable?;900;Granted by;900;Id;1;
50;M1;Objects referenced by;Select distinct user_name(o.uid), o.name, o.type,o.id from dbo.sysdepends d, dbo.sysobjects o where d.depid=o.id and d.id =?;Owner;1500;Name;2500;Type;800;Id;1;
51;M1;Objects referencing;Select distinct user_name(o.uid), o.name, o.type, o.id from dbo.sysdepends d, dbo.sysobjects o where d.id=o.id and d.depid =?;Owner;1500;Name;2500;Type;800;Id;1;
52;M1;Check Constraints on;Select col_name(c.id,c.colid), o.type, object_name(c.constid) from dbo.sysconstraints c, dbo.sysobjects o where o.id=c.constid and c.id =?;Column;2000;Type;800;Constraint Name;2000;
53;M1;Indexes on;Select i.name, i.indid, case i.status & 2048 when 2048 then 'Y' end, case i.status & 16 when 16 then 'Y' end , case i.status & 2 when 2 then 'Y' end , index_col(user_name(o.uid)+'.'+o.name,indid,1), index_col(user_name(o.uid)+'.'+o.name,indid,2), index_col(user_name(o.uid)+'.'+o.name,indid,3), index_col(user_name(o.uid)+'.'+o.name,indid,4),index_col(user_name(o.uid)+'.'+o.name,indid,5),i.id,indid from dbo.sysindexes i,dbo.sysobjects o WHERE o.id=i.id and o.id =? and indid between 1 and 254 order by 2;Name;1800;Id;400;PK?;400;Clust?;600;Uniq?;600;Column 1;1500;Column 2;1500;Column 3;1500;Column 4;1500;Column 5;1500;Id;1;Indid;1;
54;M1;Users with Role;Select name,uid from dbo.sysusers where gid=? order by 1;User;1800;Id;1;
55;M1;Roles for user;Select b.name, b.uid from dbo.sysusers a, dbo.sysusers b where a.uid=? and a.gid=b.uid order by 1;Role;1800;Id;1;
56;A1;Table access grid for;Select user_name(o.uid),o.name, (case action when 193 then 'SELECT' when 195 then 'INSERT' when 196 then 'DELETE' when 197 then 'UPDATE' when 26 then 'REFERENCES' when 224 then 'EXECUTE' end), case protecttype when 204 then 'YES' when 205 then 'NO' when 206 then 'REV' end, user_name(p.grantor), p.id from dbo.sysprotects p, dbo.sysobjects o where p.uid=? and p.id=o.id and o.type in ('S','U','V') order by 1,2,3;Owner;1500;Name;1800;Select;600;Update;700;Insert;600;Delete;600;References;1000;Execute;800;Id;1;
57;M1;Sections in Procedure;Select distinct number, id , number from dbo.syscomments where id=? order by number;Procedure Section;1500;Id;1;Number;1;
58;M1;Procedure authorities for;Select user_name(o.uid),o.name, (case action when 193 then 'SELECT' when 195 then 'INSERT' when 196 then 'DELETE' when 197 then 'UPDATE' when 26 then 'REFERENCES' when 224 then 'EXECUTE' end), case protecttype when 204 then 'YES' when 205 then 'NO' when 206 then 'REV' end, user_name(p.grantor), p.id from dbo.sysprotects p, dbo.sysobjects o where p.uid=? and p.id=o.id and o.type in ('P','X') order by 1,2,3;Owner;1500;Name;1800;Privilege;1000;Grantable?;900;Granted by;900;Id;1;
59;M1;Access list for;Select user_name(uid), (case action when 193 then 'SELECT' when 195 then 'INSERT' when 196 then 'DELETE' when 197 then 'UPDATE' when 26 then 'REFERENCES' when 224 then 'EXECUTE' end), case protecttype when 204 then 'YES' when 205 then 'NO' when 206 then 'REV' else convert(char,protecttype) end, id from dbo.sysprotects where id=? ;User;1500;Privilege;1200;Grantable?;1000;Id;1;
60;M1;Column list (simple) for;Select c.name,t.name, c.length, c.scale, case c.status & 8 when 8 then 'Y' else 'N' end, '' from dbo.syscolumns c, dbo.systypes t where c.usertype=t.usertype and c.id =? order by c.number, c.colid;Name;2000;Type;800;Length;600;Scale;600;Nulls;600;
61;M1;Columns using Rule;Select user_name(b.uid),b.name,a.name,a.id from dbo.syscolumns a, dbo.sysobjects b WHERE a.domain=? and a.id=b.id ;Owner;1500;Table;2000;Column;2000;Id;1;
62;M2;Parameters for section;Select c.name, t.name, c.length, c.scale, case c.status & 8 when 8 then 'Y' else 'N' end, case c.status&0x40 when 0 then 'IN' else 'OUT' end from dbo.syscolumns c, dbo.systypes t where c.type=t.type and c.usertype=t.usertype and c.id=? and c.number=? order by c.colid;Name;2000;Type;800;Length;600;Scale;600;Nulls;600;Usage;600;
63;M1;Column Rules for;Select user_name(c.uid),c.name,a.name,b.text,c.id from dbo.syscolumns a,dbo.syscomments b, dbo.sysobjects c WHERE a.id=? and a.domain=b.id and a.domain=c.id;Owner;1500;Rule Name;1800;Column;1800;Rule Text;2000;Id;1;
64;M1;Base Table for;Select user_name(b.uid), b.name, (case when b.deltrig = a.id then 'Delete' when b.updtrig= a.id then 'Update' when b.instrig = a.id then 'Insert' end ), b.id from dbo.sysobjects a, dbo.sysobjects b where (b.deltrig = a.id or b.updtrig= a.id or b.instrig = a.id ) and a.id=?;Owner;1500;Table Name;2000;Event;1000;Id;1;
65;M1;Defaults using Rule;Select user_name(b.uid),b.name,a.name,b.id from dbo.syscolumns a, dbo.sysobjects b WHERE a.cdefault=? and a.id=b.id ;Owner;1500;Table;1800;Column;2000;Id;1;
66;E;Column list for;Select c.name, t2.name, c.length, c.scale, case c.status & 8 when 8 then 'Y' else 'N' end, case when t.name<>t2.name then t.name else '' end from dbo.sysusers u, dbo.sysobjects o, dbo.syscolumns c, dbo.systypes t, dbo.systypes t2 where u.name='?' and u.uid=o.uid and o.name='?' and o.id=c.id and c.usertype=t.usertype and t.type=t2.type and t2.usertype=(select min(usertype) from dbo.systypes where type=t2.type and usertype>0) order by c.colid,t2.name;Name;2000;Type;800;Length;600;Scale;600;Nulls;600;User Type;1500;
67;S1;Full details of user;Select * from dbo.sysusers where uid=?;Column;1500;Value;3000;
68;M1;Login for user;select a.name, dbname From master.dbo.syslogins a, dbo.sysusers b Where a.suid = b.suid and b.uid=?;Login Name;1500;Default Database;2000;
69;Q1;View as Query;Select text from dbo.syscomments where id=? and texttype=2 order by colid;View Text;5430;