Use of IS_MEMBER function with multiple databases

Luciano Pinto 1 Reputation point
2022-04-06T13:05:48.13+00:00

Hi,

I'm having the following problem

cenario:

1 -StoreProcedure A in database A calls Function B from Database B
2- Function B:
Return IS_MEMBER('ROLE')
3- the current user is a member of 'ROLE' on database B and not a member on Database A

In SQLServer 2019 when i call StoreProcedure A from Database A it returns 'False', but if i call Function B from database B it returns true.

With SQLServer 2016 both return true;

Was there a change 2019? Is it a server configuration? Documentation doesn't mention any changes.

Any help or insights would be much appreciated.

Best Regards

Developer technologies | Transact-SQL
Developer technologies | Transact-SQL

A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.


4 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    1 deleted comment

    Comments have been turned off. Learn more

  2. Naomi Nosonovsky 8,906 Reputation points
    2022-04-07T13:51:17.76+00:00

    Are you logged as this user in both SQL Server instances? Your function checks rights of the currently logged user.

    Was this answer helpful?


  3. Luciano Pinto 1 Reputation point
    2022-04-07T10:42:10.397+00:00

    Ok, ill try to show the snipets:
    as u can see the user 'Anacarvalho' exists in both Test_DBA and Test_DBB however it only has the ROLE 'RoleA' in Test_DBB

    190818-image.png

    consider the folowing function in Test_DBB

    190934-image.png

    when i execute in 2019:

    190927-image.png

    when executed in 2016
    190885-image.png

    any thouts?

    Was this answer helpful?


  4. Erland Sommarskog 138.7K Reputation points MVP Volunteer Moderator
    2022-04-06T21:58:23.177+00:00

    We would need to see a repro that demonstrates the issue. The repro would have to create the databases, the user and the role.

    Most likely when you test it, you will find that the result is the same on SQL 2016 and SQL 2019.

    My guess is that the difference you are seeing is due to that permissions are set up differently.

    But as I said, provide a repro, if you want us to take a closer look.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.