• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • 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.

Thanks.
0
patd1
Asked:
patd1
1 Solution
 
PadawanDBACommented:
You should be able to use:

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

Open in new window



Edit:

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

use <databaseNameHere>;

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

Open in new window

0
 
patd1Author Commented:
Thank You. Alter role works for me.
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

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