• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

set the role_membership for this user after the restore

Using sql server 2012 std edition

I am restoring a database on another server as part of my sql job and then running some data processing jobs on the restored data.

The problem that I am facing is that the windows user that the data processing job runs under, loses the db_owner role_membership  after the restore so the data processing job fails while running data reads.

How can I set the role membership for this windows user using t-sql after the restore step, and before data processing. I can run this t-sql under a different sql user.

1 Solution
PadawanDBAOperational DBACommented:
You should be able to use:

alter role "db_owner" add member "<usernameHere>";

Open in new window


You will likely need to add the user to the database too:

use <databaseNameHere>;

create user "<usernameHere>" for login "<usernameHere>";

Open in new window

patd1Author Commented:
Thank You. Alter role works for me.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now