Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a user in an SQL Server database with the same rights as in another one on the same server?

Tags:

sql

sql-server

I have a server in SQL Server Management Studio, in this one when I open the "Security" folder, then "Connections" I have different user accounts already created.

I have two databases: RCE, and RCE_Finance_BI. In the first one in the "Security" folder, then "Users" I have these accounts :

enter image description here

Including JeromeRCE who has write and read rights on this database.

Now in the RCE_Finance_BI database I have these users:

enter image description here

I would like to add to this database the JeromeRCE account and give him the same rights as in the RCE database, i.e. read and write rights.

How can I do it please?

like image 426
Theo27 Avatar asked Nov 23 '25 11:11

Theo27


1 Answers

Yes you can do it.

  1. use the below script
USE [RCE_Finance_BI]
GO

CREATE USER [JeromeRCE] FOR LOGIN [JeromeRCE] WITH DEFAULT_SCHEMA=[dbo]
GO

Or you can create the script by below steps

  1. Right click the user
  2. Select 'Script User as'
  3. Select 'Create To'
  4. Select 'New Query Editor Window'
  5. Change the database to you target database in the script.

enter image description here

like image 144
Annamalai D Avatar answered Nov 26 '25 02:11

Annamalai D