jdidi
jdidi

Reputation: 159

SQLCMD MODE - Incorrect syntax near 'S'

In SSMS, when I execute

sqlcmd -S "flynetSrv"

I get :

Msg 102, Level 15, State 1, Line 3
Incorrect syntax near 'S'.

I am already connected to the server through SSMS

I also tried

sqlcmd -d "dbname1"

Msg 102, Level 15, State 1, Line 3
Incorrect syntax near 'd'.

Please help?

Upvotes: 3

Views: 4884

Answers (1)

giammin
giammin

Reputation: 18958

sqlcmd is an utility intended to be used in a command prompt

You cannot use it in a SQL Server Management Studio (SSMS) query window

You can only write or edit SQLCMD scripts within the query window enabling the SQLCMD mode (Query menu -> SQLCMD Mode)

From MSDN - Editing SQLCMD Scripts with Query Editor:

To use the Database Engine Query Editor to write or edit SQLCMD scripts, you must enable the SQLCMD scripting mode.

Upvotes: 3

Related Questions