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!