Skip to main content
replaced http://sqlblog.com/blogs/adam_machanic/archive/2012/03/22/released-who-is-active-v11-11.aspx with http://whoisactive.com
Source Link

for the users that do not have a login in the server follow this link:

--technet article on orphaned users

Report on failed users - shows all SQL users on server

USE [<database>]
EXEC sp_change_users_login  'REPORT'

--SQL 2000 and earlier
USE [<database>]
EXEC sp_change_users_login  'Auto_Fix', 'MyUser'

--SQL 2005 onwards
USE [<database>]
ALTER USER [MyUser] WITH LOGIN = [MyUser]

--to find database users (windows accounts) without Server login
select users.name, logins.name
from master..syslogins logins 
    right join sysusers users on logins.sid = users.sid 
where logins.sid is null 
   and issqlrole <> 1 
   and isapprole <> 1   
   and (users.name <> 'INFORMATION_SCHEMA' 
    and users.name not in ('guest', 'dbo', 'sys', 'system_function_schema'))
     

a number of process running for a long time that are blocking and causing other issues

for this I recommend the procedure called sp_whoisactivesp_whoisactive

for the users that do not have a login in the server follow this link:

--technet article on orphaned users

Report on failed users - shows all SQL users on server

USE [<database>]
EXEC sp_change_users_login  'REPORT'

--SQL 2000 and earlier
USE [<database>]
EXEC sp_change_users_login  'Auto_Fix', 'MyUser'

--SQL 2005 onwards
USE [<database>]
ALTER USER [MyUser] WITH LOGIN = [MyUser]

--to find database users (windows accounts) without Server login
select users.name, logins.name
from master..syslogins logins 
    right join sysusers users on logins.sid = users.sid 
where logins.sid is null 
   and issqlrole <> 1 
   and isapprole <> 1   
   and (users.name <> 'INFORMATION_SCHEMA' 
    and users.name not in ('guest', 'dbo', 'sys', 'system_function_schema'))
     

a number of process running for a long time that are blocking and causing other issues

for this I recommend the procedure called sp_whoisactive

for the users that do not have a login in the server follow this link:

--technet article on orphaned users

Report on failed users - shows all SQL users on server

USE [<database>]
EXEC sp_change_users_login  'REPORT'

--SQL 2000 and earlier
USE [<database>]
EXEC sp_change_users_login  'Auto_Fix', 'MyUser'

--SQL 2005 onwards
USE [<database>]
ALTER USER [MyUser] WITH LOGIN = [MyUser]

--to find database users (windows accounts) without Server login
select users.name, logins.name
from master..syslogins logins 
    right join sysusers users on logins.sid = users.sid 
where logins.sid is null 
   and issqlrole <> 1 
   and isapprole <> 1   
   and (users.name <> 'INFORMATION_SCHEMA' 
    and users.name not in ('guest', 'dbo', 'sys', 'system_function_schema'))
     

a number of process running for a long time that are blocking and causing other issues

for this I recommend the procedure called sp_whoisactive

Rollback to Revision 1
Source Link
Mark Sinkinson
  • 10.6k
  • 4
  • 46
  • 54

for the users that do not have a login in the server follow this link:

--technet article on orphaned users

Report on failed users - shows all SQL users on server

USE [<database>]
EXEC sp_change_users_login  'REPORT'

--SQL 2000 and earlier
USE [<database>]
EXEC sp_change_users_login  'Auto_Fix', 'MyUser'

--SQL 2005 onwards
USE [<database>]
ALTER USER [MyUser] WITH LOGIN = [MyUser]

--to find database users (windows accounts) without Server login
select users.name, logins.name
from master..syslogins logins 
    right join sysusers users on logins.sid = users.sid 
where logins.sid is null 
   and issqlrole <> 1 
   and isapprole <> 1   
   and (users.name <> 'INFORMATION_SCHEMA' 
    and users.name not in ('guest', 'dbo', 'sys', 'system_function_schema'))
     

a number of process running for a long time that are blocking and causing other issues

for this I recommend the procedure called sp_whoisactive

I have already checked for orphaned users since it is the obvious thing. I also use sp_whoisactive, sp_blitzfirst and beta_lockinfo as tools other than scripts in my toolkit.

for the users that do not have a login in the server follow this link:

--technet article on orphaned users

Report on failed users - shows all SQL users on server

USE [<database>]
EXEC sp_change_users_login  'REPORT'

--SQL 2000 and earlier
USE [<database>]
EXEC sp_change_users_login  'Auto_Fix', 'MyUser'

--SQL 2005 onwards
USE [<database>]
ALTER USER [MyUser] WITH LOGIN = [MyUser]

--to find database users (windows accounts) without Server login
select users.name, logins.name
from master..syslogins logins 
    right join sysusers users on logins.sid = users.sid 
where logins.sid is null 
   and issqlrole <> 1 
   and isapprole <> 1   
   and (users.name <> 'INFORMATION_SCHEMA' 
    and users.name not in ('guest', 'dbo', 'sys', 'system_function_schema'))
     

a number of process running for a long time that are blocking and causing other issues

for this I recommend the procedure called sp_whoisactive

I have already checked for orphaned users since it is the obvious thing. I also use sp_whoisactive, sp_blitzfirst and beta_lockinfo as tools other than scripts in my toolkit.

for the users that do not have a login in the server follow this link:

--technet article on orphaned users

Report on failed users - shows all SQL users on server

USE [<database>]
EXEC sp_change_users_login  'REPORT'

--SQL 2000 and earlier
USE [<database>]
EXEC sp_change_users_login  'Auto_Fix', 'MyUser'

--SQL 2005 onwards
USE [<database>]
ALTER USER [MyUser] WITH LOGIN = [MyUser]

--to find database users (windows accounts) without Server login
select users.name, logins.name
from master..syslogins logins 
    right join sysusers users on logins.sid = users.sid 
where logins.sid is null 
   and issqlrole <> 1 
   and isapprole <> 1   
   and (users.name <> 'INFORMATION_SCHEMA' 
    and users.name not in ('guest', 'dbo', 'sys', 'system_function_schema'))
     

a number of process running for a long time that are blocking and causing other issues

for this I recommend the procedure called sp_whoisactive

already tried your suggestion, slightly soften tone of final paragraph.
Source Link
RLF
  • 14k
  • 2
  • 34
  • 47

for the users that do not have a login in the server follow this link:

--technet article on orphaned users

Report on failed users - shows all SQL users on server

USE [<database>]
EXEC sp_change_users_login  'REPORT'

--SQL 2000 and earlier
USE [<database>]
EXEC sp_change_users_login  'Auto_Fix', 'MyUser'

--SQL 2005 onwards
USE [<database>]
ALTER USER [MyUser] WITH LOGIN = [MyUser]

--to find database users (windows accounts) without Server login
select users.name, logins.name
from master..syslogins logins 
    right join sysusers users on logins.sid = users.sid 
where logins.sid is null 
   and issqlrole <> 1 
   and isapprole <> 1   
   and (users.name <> 'INFORMATION_SCHEMA' 
    and users.name not in ('guest', 'dbo', 'sys', 'system_function_schema'))
     

a number of process running for a long time that are blocking and causing other issues

for this I recommend the procedure called sp_whoisactive

I hadhave already checked for orphaned users since it is the obvious thing. I alwaysalso use sp_whoisactive, sp_blitzfirst and beta_lockinfo as tools other than scripts in my toolkit.

for the users that do not have a login in the server follow this link:

--technet article on orphaned users

Report on failed users - shows all SQL users on server

USE [<database>]
EXEC sp_change_users_login  'REPORT'

--SQL 2000 and earlier
USE [<database>]
EXEC sp_change_users_login  'Auto_Fix', 'MyUser'

--SQL 2005 onwards
USE [<database>]
ALTER USER [MyUser] WITH LOGIN = [MyUser]

--to find database users (windows accounts) without Server login
select users.name, logins.name
from master..syslogins logins 
    right join sysusers users on logins.sid = users.sid 
where logins.sid is null 
   and issqlrole <> 1 
   and isapprole <> 1   
   and (users.name <> 'INFORMATION_SCHEMA' 
    and users.name not in ('guest', 'dbo', 'sys', 'system_function_schema'))
     

a number of process running for a long time that are blocking and causing other issues

for this I recommend the procedure called sp_whoisactive

I had already checked for orphaned users since it is the obvious thing. I always use sp_whoisactive, sp_blitzfirst and beta_lockinfo as tools other than scripts in my toolkit.

for the users that do not have a login in the server follow this link:

--technet article on orphaned users

Report on failed users - shows all SQL users on server

USE [<database>]
EXEC sp_change_users_login  'REPORT'

--SQL 2000 and earlier
USE [<database>]
EXEC sp_change_users_login  'Auto_Fix', 'MyUser'

--SQL 2005 onwards
USE [<database>]
ALTER USER [MyUser] WITH LOGIN = [MyUser]

--to find database users (windows accounts) without Server login
select users.name, logins.name
from master..syslogins logins 
    right join sysusers users on logins.sid = users.sid 
where logins.sid is null 
   and issqlrole <> 1 
   and isapprole <> 1   
   and (users.name <> 'INFORMATION_SCHEMA' 
    and users.name not in ('guest', 'dbo', 'sys', 'system_function_schema'))
     

a number of process running for a long time that are blocking and causing other issues

for this I recommend the procedure called sp_whoisactive

I have already checked for orphaned users since it is the obvious thing. I also use sp_whoisactive, sp_blitzfirst and beta_lockinfo as tools other than scripts in my toolkit.

Source Link
Marcello Miorelli
  • 16.6k
  • 53
  • 170
  • 311
Loading