-1

I am trying to automatically execute a SQL script with a batch file. Here is what I have in my batch file

@echo off

dbisql  -c "Server=servername ;DBN=databasename ;UID=UserID;PWD=password" SqlFile.sql  

pause

It says that the server was not found

Dave
  • 5,108
  • 16
  • 30
  • 40
Inquisitor
  • 15
  • 1
  • 7
  • Do I have all the parameters I need? Why is it not working? – Inquisitor Apr 08 '19 at 15:07
  • 1
    We need more information. Is the server running on the same machine? What command did you use to start the server? – Graeme Perrow Apr 09 '19 at 16:33
  • I think I have a better idea. Apparently, I can export data from SQL Anywhere using an output to statement. However, when I tried to put an output to statement in a procedure or an event, I get an error message: create procedure TestProcedure as begin SELECT * FROM test OUTPUT TO 'C:\\...filename.txt' FORMAT TEXT end – Inquisitor Apr 10 '19 at 19:57
  • The server is not on the same machine. I didn't know that I had to issue a command to start the server – Inquisitor Apr 10 '19 at 20:04

1 Answers1

0

If the server is not on the same machine, you have to tell the client that. You can do that in one of two ways:

  1. Add the hostname of the machine where the server is running to the connection string, like: Server=<servername>;...;host=<hostname>. If the server is not running on the default port (2638), you can add the port number too, using host=<hostname>:<port>. This is the preferred method.
  2. Add the links=tcpip parameter to the connection string. This is an older method and won't work if the server is on a different subnet.
Graeme Perrow
  • 56,086
  • 21
  • 82
  • 121