Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sqlcmd Unexpected Argument Error

Status
Not open for further replies.

bmacbmac

IS-IT--Management
Jan 26, 2006
392
US
Hello, in command line I am trying the following:

Code:
sqlcmd -S servername -U username -P password -d Master -Q "select name from sysdatabases"

I am getting the following message:

sqlcmd: 'name from sysdatabases"' " Unexpected argument. Enter '-?' for help.


Can anyone see what my invalid argument is?
 
Update: I tried again with something really simple:

Code:
sqlcmd -Q "select [name] from master.dbo.sysdatabases'

and still received the error:

sqlcmd: '[name] from master.dbl.sysdatabases"': unexpected argument.


The message complete omits the word 'SELECT' as though it is not being used in the script.
 
Weird.

I ran the command from your original post, replacing the server, user and password. It worked properly. I ran this command directly in a command prompt window.

Are you running this in a batch file or automated from another programming language?

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Change your trailing single quote to a double quote.

-- Francis
There are laws to protect the freedom of the press's speech, but none that are worth anything to protect the people from the press.
--Mark Twain
 
Make sure the quotes around the query string are in fact double quotes. If this has been copy/pasted from an email editor, or Microsoft's most "helpful" of tools Microsoft Word, then you may find one or more of those double quotes is in fact not a double quote.
 
Son of a !! That was it yelworcm. I just retyped and it worked.
 
You might want to get Notepad ++:
-- Francis
There are laws to protect the freedom of the press's speech, but none that are worth anything to protect the people from the press.
--Mark Twain
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top