Linked Questions

Popular Questions

I have the below python script that queries for list of SQL logins. I already had a few SQL logins that are showing up. However after I created a SQL test login it's not showing up when I run my script. Though it does show up when I run the same query on SQL Management Studio.. any thoughts?

conn = pyodbc.connect("DRIVER={SQL Server};SERVER={hostname}; \

command = ''.join(['SELECT pr.principal_id,, pr.type_desc,', 
    'pe.state_desc, pe.permission_name FROM sys.server_principals AS pr ', 
    'JOIN sys.server_permissions AS pe ON pe.grantee_principal_id = pr.principal_id ',
    'WHERE pr.type=\'S\' AND pr.is_disabled=0;'
rows = conn.execute(command)
for row in rows:
     print, row.permission_name

Related Questions