Page 1 of 1
ISQL help in DOS
Posted: 16 Jul 2010 07:58
by agrawal.meet
Hi All,
I am trying to execute a query using ISQL. Query is written in different file. Below is the command I used:
Code: Select all
isql -U <user> -P <pwd> -S <server> -D <database> -i d:\apps\cat\sql\cit_feed_getCOB.sql -o d:\apps\cat\dat\cit_date.dat
Output in cit_date.dat is:
Code: Select all
--------
20100715
(1 row affected)
But I only want isql to print data not other things. Output should be like:
Can you please tell me how can I achieve this? Again...I am not doing bcp on the table..just selecting one column.
Thanks is advance,
Meet
Re: ISQL help in DOS
Posted: 16 Jul 2010 08:10
by aGerman
I never used it, but have a look to the msdn:
http://msdn.microsoft.com/en-us/library/Aa214012What about
-h-1 ?
Regards
aGerman
Re: ISQL help in DOS
Posted: 16 Jul 2010 08:14
by agrawal.meet
Thanks for response. But -h-1 is not working
Re: ISQL help in DOS
Posted: 16 Jul 2010 08:19
by agrawal.meet
I was able to remove "1 rows effected". Can we modify the file and pick up only data into variable. I know it will always be at line 3
Re: ISQL help in DOS
Posted: 16 Jul 2010 08:30
by aGerman
If that means the data is in the last row of the file:
Code: Select all
for /f "usebackq delims=" %%a in ("d:\apps\cat\dat\cit_date.dat") do set "yourVar=%%a"
echo %yourVar%
Regards
aGerman
Re: ISQL help in DOS
Posted: 16 Jul 2010 12:26
by avery_larry
Perhaps slightly more efficient than aGerman:
If you're CERTAIN that it's on line 3, then:
Code: Select all
for /f "skip=2 usebackq delims=" %%a in ("d:\apps\cat\dat\cit_date.dat") do set "yourVar=%%a"&goto continue
:continue
echo yourvar=%yourvar%
The "&goto continue" part is only needed if the 3rd line is NOT the last line.
Basically, the skip=2 part will skip the first 2 lines, and the "&goto continue" will skip all the lines after the 3rd.
Re: ISQL help in DOS
Posted: 16 Jul 2010 19:22
by ghostmachine4
agrawal.meet wrote:[/code]
But I only want isql to print data not other things. Output should be like:
download
sed for windows, then do this
Code: Select all
c:\> sed "/-/d;/row affected/d" d:\apps\cat\dat\cit_date.dat
use a for loop to capture the output if you want
Re: ISQL help in DOS
Posted: 19 Jul 2010 00:38
by agrawal.meet
Thanks everyone for their timely reply. I am going ahead with aGerman's suggestion as my output to the file is being appended. So, not sure anymore if it will be at line 3.
Thanks again.
Thanks,
Meet