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

Ian
ipendleburyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MohammedUCommented:
Is there any special character or space in the password? if so use double quote around the password.
0
ipendleburyAuthor Commented:
No the password is just lower case characters and a digit.
0
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

/Marten
0
The Five Tenets of the Most Secure Backup

Data loss can hit a business in any number of ways. In reality, companies should expect to lose data at some point. The challenge is having a plan to recover from such an event.

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.
0
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
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.

Ian



0
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.

Cheers.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.