1

I'm trying this and it's failing

PS C:\Users\MooMin>$i = "MySQLInstanceName"
PS C:\Users\MooMin>& sqlcmd -S $i -E -q"SELECT @@VERSION"

I get this error:

Unrecognized token in source text.
At line:1 char:31
+ & sqlcmd -S "$i" -E -q"SELECT  <<<< @@VERSION"
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnrecognizedToken

What am I doing wrong?

1 Answer 1

1

A space is missing between -q and tsql statement. Try like so,

sqlcmd -S $i -E -q "SELECT @@VERSION"
Sign up to request clarification or add additional context in comments.

1 Comment

Interesting that it works in cmd.exe without the space, but not in PowerShell

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.