Can't launch OSQL with sa credentials

Posted on 2008-11-18
Last Modified: 2012-06-21
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

Question by:ipendlebury
    LVL 15

    Expert Comment

    Is there any special character or space in the password? if so use double quote around the password.

    Author Comment

    No the password is just lower case characters and a digit.
    LVL 20

    Expert Comment

    by:Marten Rune
    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


    Author Comment

    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.
    LVL 44

    Accepted Solution

    Just for testing, try to call OSQL without -P parameter and then will ask you for password.
    See if error persists.

    Good luck

    Author Comment

    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.


    LVL 44

    Expert Comment

    by:Vitor Montalvão
    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.


    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
    Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
    Viewers will learn how the fundamental information of how to create a table.
    Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now