Notifications
Mark all as read
Q&A

SID to login for access via a group

+3
−0

I have a query that returns the owner of jobs on an SQL instance,

 select s.name as JobName
, s.owner_sid
, ISNULL(L.name,'AccessViaGroup') as LoginName  --Trying to figure out how to turn that into a name.  

 from  msdb..sysjobs s 
 left join master.sys.syslogins L on s.owner_sid = L.sid 

When a job is created by someone who is logged on with access as part of group, their logon ID is displayed in the owner field of the job. Only the sid is returned in the above query. Their name/account is not in master.sys.syslogins or master.sys.server_principals it must be someplace...

My task is to return the login name, for jobs owned by accounts that have access as part of a group.

I am using SQL Enterprise 2012 to 2019.

Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

0 comments

0 answers

Sign up to answer this question »