Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

According to this kb article on what to do if your user database is gone, it recommends the following three actions

sqlcmd –E -S InstanceName –d master
1> ALTER LOGIN SQLLogin WITH DEFAULT_DATABASE = AvailDBName
2> GO

The problem here is the SQLLogin in this case is DOMAIN\user, but when I type that sqlcmd says Incorrect syntax near '\'

I've tried DOMAIN\\user and 'DOMAIN\user' but neither work.

share|improve this question
    
I typed that in the SF editor, but it collapsed it and I didn't notice, so yes, I tried that as well. –  Michael Pryor Aug 20 '09 at 15:50

2 Answers 2

up vote 6 down vote accepted

SQL is the command interpreter here, not the shell, so escaping with another \ will not work. You have to surround the login with brackets.

ALTER LOGIN [DOMAIN\Username] WITH DEFAULT_DATABASE = AvailDBName
share|improve this answer

you tried escaping it with another \ ? would be

 DOMAIN\\user
share|improve this answer
    
I typed that in the SF editor, but it collapsed it and I didn't notice (fixed now), so yes, I tried that as well. –  Michael Pryor Aug 20 '09 at 15:51
    
No. SQL is interpreting the command, not the shell. –  squillman Aug 20 '09 at 15:51
    
Sorry, should have tested it first. –  StampedeXV Aug 20 '09 at 17:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.