Solved

How to restore database permissions

Posted on 2006-11-09
4
1,020 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:
Scott Pletcher earned 63 total points
ID: 17908237
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
ID: 17908286
This problem is known as an orphaned user
http://support.microsoft.com/kb/314546
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how the fundamental information of how to create a table.

808 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