2

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.

1
  • 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
6

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
1

you tried escaping it with another \ ? would be

 DOMAIN\\user
3
  • 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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