I've list of mssql named instance in a text file. I want to read one by one in DOS batch file and replace \ with -

Vaidyanathan 1 Reputation point
2021-04-27T05:18:24.067+00:00

I've list of mssql named instance in a text file. I want to read one by one in DOS batch file and replace \ with -.

Intention : I need to connect to list of mssql instances given in a text file, and run a certain query given in sql file. And want to store the output in the csv file by naming it with respective mssql instance name.

Problem: My scripts works well as long as it is default instance i.e. named instance has \ special character in it, so could not create a csv file like HostName\instance name.csv

Ask: Is there any command in DOS bat file to replace \ with any character/letter such as - or _ or any alphabet letter?

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
12,075 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.