SQL Server Login copy all of the permisions

Rabia Kurnaz 386 Reputation points
2023-03-08T08:44:41.6333333+00:00

I am trying to copy all of the permisions (db & server level) from one login to another.

I need to a script. Help me please

Azure SQL Database
SQL Server | Other
0 comments No comments
{count} votes

Accepted answer
  1. Bjoern Peters 8,921 Reputation points
    2023-03-08T12:51:41.0733333+00:00

    Hi Rabia,

    Welcome to Q&A Forum; this is a great place to get support, answers, and tips.

    Thank you for posting your query; I'll be more than glad to help you out.

    What kind of database are you using? From those tags on your post, I can't figure that out.

    If it is a SQL Server VM, it might be different from an Azure SQL database...

    For a SQL Server, for example, you could use the PowerShell module dbatools

    https://docs.dbatools.io/Copy-DbaLogin

    Migrates logins with SIDs, passwords, defaultdb, server roles & securables, database permissions & securables, login attributes (enforce password policy, expiration, etc.)

    For an Azure SQL database, you have to use a combination of PowerShell and TSQL... where this article might lead you in the desired direction

    https://www.sqlshack.com/database-level-roles-in-azure-sql-database/

    I hope my answer is helpful to you,

    Your

    Bjoern Peters

    If the reply was helpful, please upvote and/or accept it as an answer, as this helps others in the community with similar questions. Thanks!

    2 people found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

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