Request More Information

We are hiring!

Xtivia, Inc.
2012 North America Liferay Partner of the Year

Join our top-notch team of Enterprise Java and Liferay Portal professionals in our Austin, TX office or work remotely! Please check out our current Dice listings.

Recent Bloggers

Brian Fairchild
Posts: 18
Stars: 0
Date: 5/16/13
Luke Smith
Posts: 7
Stars: 0
Date: 5/13/13
Mangesh Mharolkar
Posts: 10
Stars: 0
Date: 5/7/13
Barrie Shaw
Posts: 4
Stars: 0
Date: 4/17/13
Andrew Dalby
Posts: 2
Stars: 0
Date: 4/5/13
Tina Xing
Posts: 1
Stars: 0
Date: 3/29/13
Kaushik Nagaraj
Posts: 7
Stars: 0
Date: 3/27/13
Asier Del Pozo
Posts: 3
Stars: 0
Date: 3/27/13
Chris Shaw
Posts: 1
Stars: 0
Date: 2/26/13
Bin Zhu
Posts: 4
Stars: 0
Date: 2/24/13
« Back

Recovering from a crippled login

Quick, DBA with the sysadmin role in SQL Server: What's your default database?

I'll bet you think it's the master database. But, as I learned this weekend, that's not something you can take for granted -- especially if you didn't create the login. Our clients typically create logins for Xtivia DBAs, and in the case at hand the Xtivia login's default db was set to a user database.

I logged into the server Saturday with instructions to set this user db to single_user mode, rebuild an index and then set it back to multi_user mode. Unfortunately, once the db was in single_user mode and the index script ran, I lost my connection to the database and couldn't log back in to Management Studio (login failed with error 4064). So I couldn't set the db back to multi_user. Not good.

To recover, I logged into the database using SQLCMD, specifying a connection to the master database. Once in, I changed my default db to master, and we were once again all smiles in DBville.

Here's the command (for a named instance): 

 

C:\Users\kmaher>sqlcmd -S [server\instance] -d master
1> alter login [domain\login] with default_database = master
2> go
 
Hope this helps if you find yourself this unusual situation.

 

Comments
Trackback URL:

Join the discussion! Speak your mind! Be the first.

Request More Information