Solved

TO James   WITH GRANT OPTION;

Posted on 2014-12-15
7
94 Views
Last Modified: 2014-12-24
hi experts:

GRANT UPDATE ON Marketing.Salesperson
  TO James
  WITH GRANT OPTION;
GO

As I can get the list of users to whom James grant permissions (WITH GRANT OPTION)
0
Comment
Question by:enrique_aeo
7 Comments
 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 40503010
Great; so, what's your question?
0
 
LVL 22

Assisted Solution

by:Steve Wales
Steve Wales earned 150 total points
ID: 40503087
See the documentation for sys.database_permissions: http://msdn.microsoft.com/en-us/library/ms188367.aspx

Something like this will show you who granted what to whom:
select class, class_desc, object_name(major_id), object_name(minor_id), grantee_principal_id, b.name, grantor_principal_id, c.name, permission_name, a.type, a.state, a.state_desc
from sys.database_permissions a
join sys.database_principals b on a.grantee_principal_id = b.principal_id
join sys.database_principals c on a.grantor_principal_id = c.principal_id

Open in new window


Permissions granted with grant option would have a 'W' in state (grant with grant option), rather than 'G' (grant)
0
 
LVL 69

Expert Comment

by:ScottPletcher
ID: 40503707
DECLARE @grantor_name sysname
SET @grantor_name = 'James'

SELECT
    USER_NAME (dprm.grantee_principal_id) AS Granted_To_UserName,
    dprm.class_desc AS Object_Type,
    OBJECT_NAME(dprm.major_id) AS Object_Name,
    CASE WHEN dprm.minor_id = 0 THEN '' ELSE COL_NAME(dprm.major_id, dprm.minor_id ) END AS Column_Name,
    dprm.permission_name, dprm.state_desc
FROM sys.database_permissions dprm
WHERE dprm.grantor_principal_id = (
    SELECT grantor_principal_id
    FROM sys.database_principals dprn
    WHERE dprn.name = @grantor_name
    )
ORDER BY
   Granted_To_UserName, Object_Type, Object_Name, Column_Name
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

Author Comment

by:enrique_aeo
ID: 40507962
DROP LOGIN [James]
DROP USER [James]
GO
DROP LOGIN [JamesJunior]
DROP USER [JamesJunior]

-- Create a login and add user to MarketDEev
CREATE LOGIN [James]
WITH PASSWORD = 'Pa$$w0rd'
, CHECK_POLICY = OFF
GO
 
USE [MarketDev]
GO
 
CREATE USER [James] FOR LOGIN [James]
WITH DEFAULT_SCHEMA = [dbo]
GO

--1 Otorgando permisos a Jhon
USE MarketDev;
GO

GRANT SELECT ON Marketing.Salesperson
  TO James
  WITH GRANT OPTION;
GO


EXECUTE AS USER = 'James'
SELECT * FROM  Marketing.Salesperson
REVERT

--Creando al hijo de James
CREATE LOGIN [JamesJunior]
WITH PASSWORD = 'Pa$$w0rd'
, CHECK_POLICY = OFF
GO
 
USE [MarketDev]
GO
 
CREATE USER [JamesJunior] FOR LOGIN [JamesJunior]
WITH DEFAULT_SCHEMA = [dbo]
GO

--Otorgando permisos
EXECUTE AS USER = 'James'
GRANT SELECT ON Marketing.Salesperson
  TO JamesJunior
;
GO
REVERT

EXECUTE AS USER = 'JamesJunior'
SELECT * FROM  Marketing.Salesperson
REVERT

--Consultando 01
DECLARE @grantor_name sysname
SET @grantor_name = 'James'

I need to see James grant users permissions
0
 
LVL 69

Accepted Solution

by:
ScottPletcher earned 350 total points
ID: 40507999
Sorry, I had one copy/paste error in my code:


DECLARE @grantor_name sysname
 SET @grantor_name = 'James'

 SELECT
     USER_NAME (dprm.grantee_principal_id) AS Granted_To_UserName,
     dprm.class_desc AS Object_Type,
     OBJECT_NAME(dprm.major_id) AS Object_Name,
     CASE WHEN dprm.minor_id = 0 THEN '' ELSE COL_NAME(dprm.major_id, dprm.minor_id ) END AS Column_Name,
     dprm.permission_name, dprm.state_desc
 FROM sys.database_permissions dprm
 WHERE dprm.grantor_principal_id = (
     SELECT dprn.principal_id
     FROM sys.database_principals dprn
     WHERE dprn.name = @grantor_name
     )
 ORDER BY
    Granted_To_UserName, Object_Type, Object_Name, Column_Name
0
 

Author Comment

by:enrique_aeo
ID: 40508006
no show rows
0
 

Author Comment

by:enrique_aeo
ID: 40508060
my mistake
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Calculate values in an array 18 33
tempdb latch contention 12 49
sql server query from excel 3 57
MS SQL Pivot table help 4 14
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how the fundamental information of how to create a table.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now