Auto running SQL script I am using the below command in my batch file and running it via task scheduler.
osql -S myserver\sqlexpress -E  -i &quot;c:\test.sql&quot; -o &quot;c:\output.txt&quot;

I get the error stating that:

Server is not found or not accessible. Check if instance name is
correct and if SQL Server is configured to allow remote connections.

Could someone advise what exactly should be the myserver and sqlexpress in the above example?
I am referring the link for the above script.
How to automatically execute SQL queries with a batch file
Source: Mitel MiContact Center Knowledge Base
The -S portion of the osql command tells osql where to find the SQL instance that you want to interact with. It typically consists of two parts -- the server name and the instance name.
You'll need to replace &quot;myserver&quot; with the name of the server that your SQL installation is running on. And, if your SQL installation is using a named instance, you'll need to replace &quot;sqlexpress&quot; with the name of that instance. If, on the other hand, you installed SQL as a default instance, you can leave out the part after the backslash.
Examples
I've got SQL running on a machine named DougSQL01. As a default instance. So my osql command would look like this:
osql -S DougSQL01 -E -i &quot;c:\test.sql&quot; -o &quot;c:\output.txt&quot;

I've got another instance of SQL running on another server, DougSQL02. This one is a named instance, with an instance name of &quot;Testing&quot;. In this case, my osql command would look like this:
osql -S DougSQL02\Testing -E -i &quot;c:\test.sql&quot; -o &quot;c:\output.txt&quot;

There are some other subtleties about how to specify a server and an instance, like specifying a port instead of an instance name, using an IP address instead of a hostname,  specifying &quot;mssqlserver&quot; for a default instance, and the ability to leave out the name of the instance if a named instance is running on port 1433, but none of them are likely to apply in your case.