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.

link|improve this question

71% accept rate
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
feedback

2 Answers

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
link|improve this answer
feedback

you tried escaping it with another \ ? would be

 DOMAIN\\user
link|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
feedback

Your Answer

 
or
required, but never shown

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