Solved

How to restore database permissions

Posted on 2006-11-09
4
1,017 Views
Last Modified: 2011-03-22
We are moving a database from SQL Server 2000 to 2005.  The database seens to to restore OK, but when we run the web application we get numerous errors like "Username does not have select permission on tablename" or "execute permission denied on object storedprocedure1", etc. and we have to manually reset the permissions on every table, view and stored procedure.  How can we restore the database, including all permissions on tables, stored procedures, etc?
0
Comment
Question by:medcare
4 Comments
 
LVL 69

Accepted Solution

by:
ScottPletcher earned 63 total points
Comment Utility
The users and their permissions *are* still there.  The problem is that the user is not sync'ed up with the login.

Run the code below in Query Analyzer and then run the commands it generates.  That should re-sync the users.

SELECT 'EXEC sp_change_users_login ''UPDATE_ONE'', ''' + su.name + ''', ''' + su.name + ''''
FROM sysusers su
LEFT OUTER JOIN master..syslogins sl ON su.sid = sl.sid
WHERE su.issqluser = 1 AND su.name NOT IN ('guest', 'INFORMATION_SCHEMA')
AND sl.sid IS NULL
0
 
LVL 42

Assisted Solution

by:EugeneZ
EugeneZ earned 62 total points
Comment Utility
This problem is known as an orphaned user
http://support.microsoft.com/kb/314546
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

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 …
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

743 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

17 Experts available now in Live!

Get 1:1 Help Now