September 25, 2013 at 4:01 pm
Hello!
I am trying write a sql script to change the default database to master for multiple users at once.
The following code allows me to change the default database for one user:
ALTER LOGIN [DOMAIN\login]
WITH DEFAULT_DATABASE = master
However, for efficiency, I am trying to change the default database for multiple users at once.
Any help is highly appreciated.
Thank you,
MK
September 25, 2013 at 4:18 pm
You have to execute the command once for each user, but you can have multiple commands in your script.
September 25, 2013 at 5:26 pm
Multiple commands in the same script will do ...
September 25, 2013 at 5:26 pm
Multiple commands in the same script will do ...
September 26, 2013 at 1:17 am
Thank you very much for all those you replied back to my request. I will try your suggestions.
MK
September 26, 2013 at 3:33 pm
I was wondering whether someone could help me with creating a loop to iterate through a table (sys.syslogins) and
change the default databases to a different database for all sql logins. If successful, the users should be directed to the newly
selected database at logon. We have nearly 150 users that login to the server.
Thank you,
MK
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply