1.

Solve : Getting rid of tabs and spaces and formatting the output?

Answer»

A PART of my code:
Code: [Select]for /f "tokens=* delims=" %%v in ('isql -S %server% -D %database% -U %user% -P %pwd% -i test.sql') do (
echo %%v
)And the output returned when executing the database script is full of spaces and TABS.

prioran GSD

agerma GSD

savlahi DEV

rotheam DEV

I want to remove the tabs and spaces in between and set the first variable to the second.
let me give you an example.

set prioran=GSD and so on.

I know this needs a for loop and Findstr. Could anyone help?Code: [Select]setlocal enabledelayedexpansion
for /f "tokens=1,2" %%v in ('isql -S %server% -D %database% -U %user% -P %pwd% -i test.sql') do (
set 1=%%V
set 2=%%W
set 2=!1!)
echo %2%
this won't change the value in your sql database, just change the output vaule. to change the database you'll need something more powerful than DOS.

FBThanks FB. Appreciate the help.
The code works perfect except for this part.
Code: [Select]set 1=%%V
set 2=%%W
set 2=!1!)
echo %2%MAYBE its something I am doing wrong.
And I changed it to:
Code: [Select]set %%v=%%wwhich works.

But thanks a ton for it has solved quite a few of my issues.



Discussion

No Comment Found