Re: Using SQLCMD to test Connection



I put that command into a batch file and it still generates a syntax error, so I must be doing something wrong...

Assuming you really execute the batch file from the operating system command interpreter, then you should now have some other error compared to the one you posted earlier. If you post that, we might be able to assist.

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi


"Rubens" <rubensrose@xxxxxxxxxxx> wrote in message news:eZF12sWfIHA.3724@xxxxxxxxxxxxxxxxxxxxxxx
Hmmmm, I think I am going to have to doing some more reading about SQLCMD. I put that command into a batch file and it still generates a syntax error, so I must be doing something wrong...

Rubens

"Tibor Karaszi" <tibor_please.no.email_karaszi@xxxxxxxxxxxxxxxxxx> wrote in message news:80A1D3B3-074E-4ACF-AEBC-CDD347CE54BA@xxxxxxxxxxxxxxxx
Thanks all, but I still must be doing something wrong. I've switched SSMS into SQLCMD mode and tried running all of the following.
...
Each of these generate the following error message:

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

Above is because you are connected to SQL Server from SSMS, and SQL Server expects a SQL command. SQLCMD is not a SQL command, it is an EXE file. Run it from a bat file.


--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi


"Rubens" <rubensrose@xxxxxxxxxxx> wrote in message news:BEB5AF0C-B17A-4E4D-8DD7-1078827CE69A@xxxxxxxxxxxxxxxx
Thanks all, but I still must be doing something wrong. I've switched SSMS into SQLCMD mode and tried running all of the following.

SQLCMD -Stcp:MIS-RROSE1 -E
SQLCMD -S tcp:MIS-RROSE1 -E
SQLCMD -S tcp:{MIS-RROSE1} -E
SQLCMD -S tcp:[MIS-RROSE1] -E

SQLCMD -SMIS-RROSE1 -E
SQLCMD -S MIS-RROSE1 -E
SQLCMD -S {MIS-RROSE1} -E
SQLCMD -S [MIS-RROSE1] -E

Each of these generate the following error message:

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

Any idea? FYI... the reason I had initially tested forcing tcp on port 1433 is I'd like to verify connectivity using this specific connection. And going forward, I'd like to be able to test this way if we change the default port.

Thank-you,
Rubens

"Hans" <hansxlion@xxxxxxxxxxx> wrote in message news:2CD4AE4A-33C1-4341-A197-56AF30B930D9@xxxxxxxxxxxxxxxx
Hi, It should be like this:

SQLCMD -S tcp:ServerName -E





"Rubens" <Rubens@xxxxxxxxxxxxxxxxxxxxxxxxx> 写入消息 news:7C95C60D-3331-4481-9392-B9900CAB60C2@xxxxxxxxxxxxxxxx
I am using the following comand to test a SQL 2005 connection, but I seem to
have the syntax incorrect.

SQLCMD -Stcp:ServerName,1433 -E

What am I doing wrong?

Thanks,
Rubens




.



Relevant Pages

  • Re: Using SQLCMD to test Connection
    ... I was getting a syntax error in SSMS, but the batch file went to the first line after retyping the command in manually. ... SQLCMD allows you to enter T-SQL statements from the command prompt. ... So ideally I'd like to be able to setup a batch file for certain servers that I keep in a central location as a means of testing connectivity, some of which connect with the default instance, others might be different from the default. ...
    (microsoft.public.sqlserver.clients)
  • Re: Script to stop a SQL service
    ... Would the syntax be the same if I ran the command line script from within a ... I'm planning on running this batch file from within the BackUp Exec ... > You can also use SQL-DMO to stop/start a SQL Server instance. ... >> Is there a script that I can run to stop a particular SQL server service ...
    (comp.databases.ms-sqlserver)
  • Re: Run Batch Files with SQL Server Agent
    ... selecting 'Operating System Command ... >> I am trying to run a batch file using the SQL Server ... >> DeeJay ...
    (microsoft.public.sqlserver.server)
  • Re: How to Execute SQL Scripts using Batch file?
    ... i think Batch file should contain Username,Password,Database and ... but SQLCMD has some extra bells and whistles. ... look them up in Books Online. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ...
    (comp.databases.ms-sqlserver)
  • Re: Can XPe SP1 and SP2 co-exist on the same development machine?
    ... > There is some information about the database in the system databases too, ... > This can be done from a batch file too, through oqsl.exe (in the SQL Server ... > command line, so it's not broken in this post by the time you read it. ...
    (microsoft.public.windowsxp.embedded)

Loading