How to restore user when database is restored.

by mats.decker 24. February 2010 15:04

A thing that always annoys me, when backup-restoring a database between database servers, is the mismatch between the sql login and database login. In some way they have the same name but some id isn't equal so they don't match. Atleast in newer versions of SQL Server you could delete one and re-map it.

Stumbled across this script that matches the server login and database login.

USE [Database]
EXEC sp_change_users_login 'Update_One', 'Username', 'Username'

This only works when the usernames match.

Tags:

blog comments powered by Disqus

Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 2.5 Sweden License.


Welcome to the Dropit blog!

Here we, the people that work at Dropit, will write about stuff that interests us. For example web development, especially with .NET and EPiServer - but we'll also talk about other techniques that interest us, marketing on the web, social phenomenons, pop culture, games and software development in general.