|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Wednesday, January 23, 2013 5:19 PM
Points: 17,
Visits: 86
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, April 11, 2013 9:48 PM
Points: 1,
Visits: 51
|
|
When I try to run this script I am geting the error below:
Msg 102, Level 15, State 1, Line 14 Incorrect syntax near ' '.
It does not make any sense and I cannot find out why this error is being displayed. Has anyone else had this issue? Thanks!
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Wednesday, January 23, 2013 5:19 PM
Points: 17,
Visits: 86
|
|
The boxes ' ' representing spaces/tab, are part of the query being copied over, get rid of them and your query will execute OK.
For instance, " SELECT role_principal_id, member_principal_id FROM sys.database_role_members"
Delete the , it may not show in your query window, but just delete tab or space of line inside for it to look like "SELECT role_principal_id, member_principal_id FROM sys.database_role_members".
Do this for the rest of the line and you should be OK.
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Wednesday, July 18, 2012 1:22 AM
Points: 325,
Visits: 234
|
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Wednesday, July 18, 2012 1:22 AM
Points: 325,
Visits: 234
|
|
| just a small thing make use of table variable instaed of temp tables. or local temp table
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Wednesday, July 18, 2012 1:22 AM
Points: 325,
Visits: 234
|
|
is it possible to drill down to object level, say particular user have xyz right on abc object. eg: user1 have execute permission on procedure1?
Thanks in advance!!!!!!
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 1:15 PM
Points: 423,
Visits: 1,948
|
|
You don't need a cursor; run this from the db you want to collect information on.
SELECT sdp2.[name] as DBUser, sdp2.type_desc as DBUserType, sdp1.[name] as DBUserRole, sdp1.type_desc as DBUserRoleType FROM sys.database_role_members drm LEFT JOIN sys.database_principals sdp1 on drm.role_principal_id=sdp1.principal_id LEFT JOIN sys.database_principals sdp2 on drm.member_principal_id=sdp2.principal_id ORDER BY sdp2.name,sdp1.name
Cursors are useful if you don't know SQL
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Wednesday, January 23, 2013 5:19 PM
Points: 17,
Visits: 86
|
|
SSC-Enthusiastic, I like the script you posted, it works the same, and importantly I do not have to user a cursor and create a temp table to get the information I want.
Thanks.
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 1:15 PM
Points: 423,
Visits: 1,948
|
|
Glad you like it.
By the way, my identity is not "SSC-Enthusiastic", just as yours is not "Forum Newbie".
Generally you should try to avoid using cursors in tsql-- with few exceptions. There are some real gurus on this site, it's a great resource.
Cursors are useful if you don't know SQL
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Tuesday, May 21, 2013 11:18 AM
Points: 848,
Visits: 1,453
|
|
mstjean (2/10/2010) Glad you like it.
By the way, my identity is not "SSC-Enthusiastic", just as yours is not "Forum Newbie".
Generally you should try to avoid using cursors in tsql-- with few exceptions. There are some real gurus on this site, it's a great resource.
DITTO to the avoiding Cursors and Guru comment to.
When I first looked at this I was like thats cool but whats with the CURSOR? I assumed there must be some klind of restriction disallowing it.
Larry - Is your background in programming verses DB related?
Kindest Regards,
A Democracy works great until the day you find yourself on the sheep side of a vote between 5 wolves and 4 sheep on what’s for dinner when neither have eaten in many days. A free Republic where the rights of the few and the individual are protected is the only one in which Freedom and Prosperity for all have a chance to blossom.
|
|
|
|