This script will be used to script out the users and their permissions at the database level. We can use this when we are replacing /overrighting the existing database.
First we need to make sure we fill the following fields propertly.
>> Change the DB name in which you want to script roles
SET @DBNAME='ReportingDatabase'
>>Change the Db name where you want to store the values
SET @STORAGEDBNAME='master'
>> Use below query , copy the output and run to re create those
select * from master.DBO.TEMP_TABLE_FOR_USERS
>> Note this will ovewrite the same table if we ran more than once