osql syntax when port default

  • Hello All

    Does anyone know the syntax for using osql when the server you are attempting to access is not on the default port.

    When I connect with query analyzer, I use the following

    IP, Port

    SqlUser

    Password

    I tried

    OSQL -Usqluser -Ppassword -Sip,port

    OSQL -U sqluser -P password -S ip,port

    OSQL -Usqluser -Ppassword -S ip, port

    OSQL -Usqluser -Ppassword -S ip:port

    OSQL -Usqluser -Ppassword -S"ip,port"

    OSQL -Usqluser -Ppassword -S"ip:port"

    OSQL -Usqluser -Ppassword -Sip

    OSQL -Usqluser -Ppassword -S ip

    Depending on the syntax I always get the one following errors

    [DBNETLIB]SQL Server does not exist or access denied.

    [DBNETLIB]ConnectionOpen (Connect()).

    -or-

    [DBNETLIB]Invalid connection.

    [DBNETLIB]ConnectionOpen (ParseConnectParams()).

    Thanks,

    Steve

    Steve

  • I'm surprised this one didn't work for you; it works fine for me:

    OSQL -Usqluser -Ppassword -Sip

    You shouldn't need the port.

    Can you ping the IP?

     

  • I have found that to be an inaccurate statement.  If the port is the standard SQL default, then it is accurate to say that the port is not required.  Once the port is changed, however, all bets are off and the port specification is required. (At least it was from my tests) 

    I must have had some sort of brain burp or something because I did find something that would work.

    Ultimately the syntax was

    osql -UsqlUser -Ppassword -S"IP, Port" -- this one worked

    osql -UsqlUser -Ppassword -S"IP" -- this one did not

    If you will notice, the syntax that ultamately worked was one that I said that I had tried.  So obviously there was something wrong with my original argument set other than syntax.

    Any way, Thanks for all who bothered to look

     

    Steve

  • Sorry, I missed the comment where you specified you weren't using the default port setting.  No experience, there.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply