Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLCMD - Username gives error of unexpected argument

Tags:

sqlcmd

I am using SQLCMD to try and connect to an SQL Server to run a script. Running this script fails with an error. This is the command I run:

SQLCMD -b -S AGAPI-PC\WORKSTATION -d Asp_TestDatabase1231 -u Test -p SQL -i "C:\WorkArea\INSTALL\INSTALL\bin\Debug\Data\SQL\Install\Asp.sql" -o "C:\WorkArea\INSTALL\INSTALL\bin\Debug\Data\Logs\SQLScriptResults_Asp.sql.log"

This is the error returned:

Sqlcmd: 'Test': Unexpected argument. Enter '-?' for help.

I have tried a number of things including the following:

  1. Checked the SQL Login credentials to ensure that they were correct,
  2. Tried using no -u and -p switch and use Windows Authentication (which connected without any issues),
  3. Tried writing it into CMD manually as I had heard copying and pasting may cause issues with certain characters not being recognized,
  4. Scoured the World Wide Web for an answer

Hopefully someone has come across this before that may be able to shed some light.

like image 886
Felix Stubner Avatar asked Oct 13 '25 10:10

Felix Stubner


1 Answers

As Damien_The_Unbeliever stated:

Arguments are case sensitive. -u (unicode output) != -U.(login id)

This is also backed up by Microsoft's documentation on SQLCMD here: https://msdn.microsoft.com/en-us/library/ms162773.aspx

Upon replacing the -u switch with -U the SQLCMD command worked without any issues.

like image 84
Felix Stubner Avatar answered Oct 16 '25 08:10

Felix Stubner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!