The idea is to write a batch file to execute a query against a list of SQL servers and get some information from them, if any SQL Server is not reachable, I want this batch file to write servername\instancename to a text file for my reference.
I have around 100 SQL Server instances (in text file), when I get the result, it is hard to know which instance was unreachable during the batch file execution.
This is the script I use to get the info from the SQL Servers in (listed in text file) and it works:
for /F "tokens=*" %%S in (SQLLIST.txt) do sqlcmd -E -h -1 -W -M -S %%S -i C:\Foldername\Query.sql >> Destination\QueryResult.csv -s ","
I figure I may need to add an IF statement to do that? Please help.