Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
USE MASTER
GO
BEGIN
IF EXISTS (SELECT * FROM dbo.sysobjects
WHERE id = OBJECT_ID(N'[dbo].#TUser')
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE #TUser
CREATE TABLE #tuser (
DBName VARCHAR(50),
UserName SYSNAME,
GroupName SYSNAME NULL,
LoginName SYSNAME NULL,
uid INT,
sid VARBINARY(85))
INSERT INTO #TUser
EXEC sp_MSForEachdb
'
SELECT ''?'' as DBName,
u.name As UserName,
CASE
WHEN (r.uid IS NULL) THEN ''public''
ELSE r.name
END AS GroupName,
l.name AS LoginName,
u.uid,
u.sid
FROM ?.dbo.sysUsers u
LEFT JOIN (?.dbo.sysMembers m
JOIN ?.dbo.sysUsers r
ON m.memberuid = r.uid)
ON m.memberuid = u.uid
LEFT JOIN dbo.sysLogins l
ON u.sid = l.sid
WHERE u.islogin = 1 OR u.isntname = 1 OR u.isntgroup = 1
/*and u.name like ''tester''*/
ORDER BY u.name
'
SELECT syslogins.loginname, #Tuser.*
FROM syslogins left outer join #TUser on syslogins.loginname=#TUser.username
ORDER BY syslogins.loginname, #TUser.DBName,
#TUser.UserName,
#TUser.GroupName
DROP TABLE #TUser
END
use dbName
SELECT sysusers.NAME AS login,
sysobjects.NAME AS object,
syscolumns.NAME AS tCOLUMN,
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'
end as action
FROM [dbo].[sysprotects]
JOIN [dbo].[sysobjects] ON [sysprotects].[id]=[sysobjects].[id]
JOIN [dbo].[sysusers] ON [sysprotects].[uid]=[sysusers].[uid]
JOIN dbo.syscolumns ON sysobjects.id=syscolumns.id
WHERE sysobjects.type IN ('U','V')
ORDER BY login, object, tcolumn
It did not like it when I tried to use sp_msforeachdb
Create
Table #Temp(
DatabaseName VarChar(200),
LoginName VarChar(200),
ObjectName VarChar(200),
ColumnName VarChar(200),
Action VarChar(200))
exec sp_msforeachdb
'
Insert Into #Temp(DatabaseName, LoginName, ObjectName, ColumnName, Action)
SELECT ''?'' As DatabaseName,
sysusers.NAME AS login,
sysobjects.NAME AS object,
syscolumns.NAME AS tCOLUMN,
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''
end as action
FROM [?].[dbo].[sysprotects]
JOIN [?].[dbo].[sysobjects] ON [sysprotects].[id]=[sysobjects].[id]
JOIN [?].[dbo].[sysusers] ON [sysprotects].[uid]=[sysusers].[uid]
JOIN [?].dbo.syscolumns ON sysobjects.id=syscolumns.id
WHERE sysobjects.type IN (''U'',''V'')
ORDER BY login, object, tcolumn'
Select * From #Temp
Drop Table #Temp