Solved

set the role_membership for this user after the restore

Posted on 2014-02-17
2
190 Views
Last Modified: 2014-02-17
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
Comment
Question by:patd1
2 Comments
 
LVL 10

Accepted Solution

by:
PadawanDBA earned 500 total points
ID: 39865496
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
 

Author Closing Comment

by:patd1
ID: 39865572
Thank You. Alter role works for me.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now