简体   繁体   中英

argument in is_member() procedure

In Sql Server, I have this column NomRole which contains names of roles which i can put security on i tried this test to check is_member procedure

IF IS_MEMBER ('db_owner') = 1
   print 'current user is a member of the db_owner role'
else if IS_MEMBER(dbo.liaisecurité.NomRole) = 1 // <-- problem //

but it seems like there is a problem when i put a column instead of string in is_member() procedure it says the multi-part indentifier "dbo.liaisecurité.NomRole" could not be bound

First, to remove try dbo from under is_member() .

Try somethink like

-- Execute SELECT if user is a member of ADVWORKS\Shipping.
IF IS_MEMBER ('ADVWORKS\Shipping') = 1
   SELECT 'User ' + USER + ' is a member of ADVWORKS\Shipping.'; 
GO

and also if you want to pass variable value, use this sample

Declare @owner varchar(20)
SET @owner = 'db_owner'
SELECT IS_MEMBER(@owner)

Refer http://msdn.microsoft.com/en-us/library/ms186271.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM