Welcome to my ASP Code Website

Connecting a Login to a Database User

When you restore a database onto a server, it restores the database's tables along with the users that own those tables. However, it does NOT create the actual logon accounts to log into the MS-SQL database with. If you then try to create a logon account and connect it to that database, the system will complain that the database user already exists!

Here's the solution. Let's say your database is called "MyDB". You would do:



EXEC sp_change_users_login 'Update_One', 'USERNAME', 'LOGONNAME'

The Update_One is the actual letters for that field - it says to update the logon name. The USERNAME should be replaced with the username that owns the tables. The LOGONNAME should be replaced with the new logon name you have created.

ASP Server Setup Information