I have script which generates SQL's with variables.
@echo off
set "YYYY=2013"
set "YY=13"
set "MM=03"
set "LOCATION=D://DCOUMENTS/SQLSCRIPT/"
select count(*) from table1 where filedirectory='XXXXX' and file_name like 'ABC_percentage_%YYYY%%MM%__.txt'; >> %LOCATION%Generated_Script.sql
select count(*) from table2 where filedirectory='XXXXX' and file_name like 'ABC_percentage_%YYYY%%MM%__.txt'; >> %LOCATION%Generated_Script.sql
select count(*) from table3 where filedirectory='XXXXX' and file_name like 'ABC_percentage_%YYYY%%MM%__.txt'; >> %LOCATION%Generated_Script.sql
--After loading all sql's INTO %LOCATION%Generated_Script.sql. I want to find "percentage" and replace with "%" character.
Can someone help me to create a script finding "percentage" and replace with "%". I tried to create but its not working may be because of % character.
Appreciate your help in this. thanks in advance
Find and replace in a file
Moderator: DosItHelp
Re: Find and replace in a file
echo %% will create a single % character
Show us the code that you have tried.
Show us the code that you have tried.
Re: Find and replace in a file
foxidrive wrote:echo %% will create a single % character
Show us the code that you have tried.
Thanks foxidrive.
Your tip help me to resolve the issue. Now I dont need to find and replace it.
@echo off
set "YYYY=2013"
set "YY=13"
set "MM=03"
set "LOCATION=D://DCOUMENTS/SQLSCRIPT/"
select count(*) from table1 where filedirectory='XXXXX' and file_name like 'ABC_%%_%YYYY%%MM%__.txt'; >> %LOCATION%Generated_Script.sql
select count(*) from table2 where filedirectory='XXXXX' and file_name like 'ABC_%%_%YYYY%%MM%__.txt'; >> %LOCATION%Generated_Script.sql
select count(*) from table3 where filedirectory='XXXXX' and file_name like 'ABC_%%_%YYYY%%MM%__.txt'; >> %LOCATION%Generated_Script.sql
Re: Find and replace in a file
sri2002 wrote:Thanks foxidrive.
Your tip help me to resolve the issue. Now I dont need to find and replace it.
That's great. It's better to solve the issue in the first instance.
