Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 User Login

Author  Topic 

Derick
Starting Member

17 Posts

Posted - 2010-07-19 : 05:54:03
Hi All,
I’m developing on two different machines and both these machines are setup the same. The thing is every time I need to work on the other machine and change the connection string I need to delete the user in my db and recreate it. When I change and I open the user there is no login in the user account. The login account is still there but I have to delete the user and recreate the user account to get the login linked to the user account. Is there code I can use in sql to add a login to a user account?

Many Thanks


Do something out of character each day this week. Change your hairstyle, wear a different colour, show your teeth when you smile, eat chocolate-anything! Just choose to be different because you can!

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2010-07-19 : 06:55:17
Take a look at: sp_change_users_login

This behaviour will not occur be simply changing your connection string.
The sql user can become orphaned from its login when a database is restored from one instance to another. Is a database restore performed?
Go to Top of Page

Derick
Starting Member

17 Posts

Posted - 2010-07-19 : 07:06:07
Hi YellowBug thanks for the reply,
The db is on my external HD and when I'm at home I'll plug it in and work and same at office. I think this is the cause, but I need a better way to get the login back on the user account. How will I use sp_change_users_login?

Do something out of character each day this week. Change your hairstyle, wear a different colour, show your teeth when you smile, eat chocolate-anything! Just choose to be different because you can!
Go to Top of Page

Derick
Starting Member

17 Posts

Posted - 2010-07-19 : 08:26:20
Thanks sp_change_users_login is working 100%

Do something out of character each day this week. Change your hairstyle, wear a different colour, show your teeth when you smile, eat chocolate-anything! Just choose to be different because you can!
Go to Top of Page
   

- Advertisement -