I have a folder that I generated about 100 .sql files in to make table changes to various schemas in a database.
I am trying to use a the method in this post to run my 100 sql files, but I keep getting the errors. It works for the first few files, and then I start getting
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Named Pipes Provider: Could not open a connection to SQL Server [53]. .
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
I know its configured for remote connections, another application on another VM uses it, and I checked the servers properties as well. The first 5-6 SQL files DO run, but then it stalls out and I start getting this issue. Any thoughts on what is causing it and how to mitigate it? Am I just trying to do too much at once?
UPDATE: The code in my batch file
for %%G in (*.sql) do sqlcmd /S ServerName /d MyDatabase -U MyUser -P "MyPassword" -i"%%G"