Error when running batch file


    I have a batch file, with the command to drop the tables from the server database. The command works in the database but when I ran the file it gives me an error executing my T-SQL Table dropping script:

    Sqlcmd: 'ds.user': Unexpected argument. Enter '-?' for help.

    Any idea what might be the problem?

    @echo off

    @echo Executing my T-SQL Table dropping script

    SQLCMD -Q "drop table [dbo].[cat]" -s -d The........pit -u ds.user -p Le....ql


    I have tried to change the case for -U and -P and got another error:

    Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login failed for user 'ds.user'..

  • I suggest you read the SQLCMD documentation again.

    If ds.user is a login then you have to use -U and the same -P for the password.

    -u and -p have totally different usage in SQLCMD


    as you have said you have tried -U and -P and got a login error, I would start by looking at fixing that first.  Find the needed 18456 error in the SQL Log and then track the state back to the right failure condition.

  • This was removed by the editor as SPAM

  • This was removed by the editor as SPAM

  • Hello this is Gulshan Negi

    Well, the error message seems related to the argument passed to the SQLCMD utility. It's possible that there is an error in the syntax of the command or that the wrong argument is being passed. To resolve the issue with the T-SQL table-dropping script, you should review the syntax and arguments used in the SQLCMD command in the batch file. Make sure that the server name and database name used in the command is correct and accessible, and check for any special characters or spaces that may need to be properly escaped or enclosed in quotes. If the issue persists, test the SQLCMD command manually and seek assistance from a database administrator or technical support team.

    Hope it will help you.



  • Heh... old post I know but, for others reading this, stop putting login names and passwords in clear text in batch files.  Use only proper "trusted connections".

    --Jeff Moden

    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 6 posts - 1 through 5 (of 5 total)

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