• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 718
  • Last Modified:

Can't launch OSQL with sa credentials

I just started using OSQL today for the first time to access MSDE on my home pc. I found that I cannot launch it by using the sa credentials. However it will allow me to use a trusted connection. Here the command line that doesn't work.

OSQL -S MyServer -U sa - P saPassword - d master.........

While this does work

OSQL -S MyServer -E - d master.........

The wierd thing is that Query Analyzer accepts the same sa credentials without a problem. Help please

1 Solution
Is there any special character or space in the password? if so use double quote around the password.
ipendleburyAuthor Commented:
No the password is just lower case characters and a digit.
Marten RuneSQL Expert/Infrastructure ArchitectCommented:
Your problem is a extra space. You type:
OSQL -S MyServer -U sa - P saPassword - d master

When ist should be:
OSQL -S MyServer -U sa -P saPassword - d master

You have typed -<space>P instead of -P

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

ipendleburyAuthor Commented:
Well spotted! but unfortunately that was just an error when I posted the question in here. I didn't make that mistake in my batch file. I just tried it again and got the same error.
Vitor MontalvãoMSSQL Senior EngineerCommented:
Just for testing, try to call OSQL without -P parameter and then will ask you for password.
See if error persists.

Good luck
ipendleburyAuthor Commented:
I'm totaly confused now... I just tried it without the -P switch. It asked me for the password and accepted it. So I put the -P password back in and it still worked!!

I know I checked this so carefully yesterday. There's no way I had the wrong password in there. Especially when I was putting the same password in Query Analyzer. So I don't know how to explain this. But it works now so I'll thank everyone for their input.


Vitor MontalvãoMSSQL Senior EngineerCommented:
Ian, I know it's weird and that's why I asked you to take off -P parameter.
Sometimes we are so used to do the same thing that we went in automatic mode and if there's any mistake we'll keep doing it. So the best way is to ask to someone to do it once for us or if we can just change the way we do it.
The most important as you have your problem solved.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now