Home All Groups Group Topic Archive Search About

How to retrive rows from MS SQL server from batch script

Author
10 Aug 2006 4:12 PM
Ian
From my batch script I am able to count the number of rows that satisfy a
query but not able to retrieve the rows.

For example, these work:
1 - select count(*) from unsupported
2 - select count(*) from unsupported where systemname = 'tracker'

The results are 450 and 1, respectively.

But replace the "COUNT(*)" with just "*", and no data is returned and no
errors.

The table has 450 entries and only three fileds, systemname, OS and release.

Thanks in advance for any help.

Ian

Author
10 Aug 2006 4:20 PM
Immy
can you post the content of your batch script?

Show quote
"Ian" <I**@discussions.microsoft.com> wrote in message
news:0E4D6E40-D2A0-4382-81F0-A27778CDB96E@microsoft.com...
> From my batch script I am able to count the number of rows that satisfy a
> query but not able to retrieve the rows.
>
> For example, these work:
> 1 - select count(*) from unsupported
> 2 - select count(*) from unsupported where systemname = 'tracker'
>
> The results are 450 and 1, respectively.
>
> But replace the "COUNT(*)" with just "*", and no data is returned and no
> errors.
>
> The table has 450 entries and only three fileds, systemname, OS and
> release.
>
> Thanks in advance for any help.
>
> Ian
>
Author
10 Aug 2006 5:11 PM
Ian
Here it is Immy:

@echo on
setlocal
set sqlpath=\progra~1\micros~1\80\tools\binn
set sqlsvr=sharedbps1
set user="ian.guthrie"
set passwd=[…removed to protect the innocent. :-)]
set path=\progra~1\centennial\admin\bin
set unsupprpt=\progra~1\centennial\admin\log\unsupprpt.txt
date /t > %unsupprpt%
echo Unsuported unix OSes:  >> %unsupprpt%

%sqlpath%\osql -S%sqlsvr% -U%user% -P%passwd% -Q "use DiscUnSuppt;SELECT *
FROM unsupported WHERE SystemName = 'tracker'" >>%unsupprpt%

echo ==============END of Report ============== >> %unsupprpt%
endlocal


Show quote
"Immy" wrote:

> can you post the content of your batch script?
>
> "Ian" <I**@discussions.microsoft.com> wrote in message
> news:0E4D6E40-D2A0-4382-81F0-A27778CDB96E@microsoft.com...
> > From my batch script I am able to count the number of rows that satisfy a
> > query but not able to retrieve the rows.
> >
> > For example, these work:
> > 1 - select count(*) from unsupported
> > 2 - select count(*) from unsupported where systemname = 'tracker'
> >
> > The results are 450 and 1, respectively.
> >
> > But replace the "COUNT(*)" with just "*", and no data is returned and no
> > errors.
> >
> > The table has 450 entries and only three fileds, systemname, OS and
> > release.
> >
> > Thanks in advance for any help.
> >
> > Ian
> >
>
>
>
Author
10 Aug 2006 4:40 PM
Arnie Rowland
If you are using OSQL, you could just provide an Output file. Otherwise, the
data goes to the screen and is not capturable in a batch operation.

See Books on Line for detailed usage instructions, especially the -o
"filepath/filename" argument.

--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous


Show quote
"Ian" <I**@discussions.microsoft.com> wrote in message
news:0E4D6E40-D2A0-4382-81F0-A27778CDB96E@microsoft.com...
> From my batch script I am able to count the number of rows that satisfy a
> query but not able to retrieve the rows.
>
> For example, these work:
> 1 - select count(*) from unsupported
> 2 - select count(*) from unsupported where systemname = 'tracker'
>
> The results are 450 and 1, respectively.
>
> But replace the "COUNT(*)" with just "*", and no data is returned and no
> errors.
>
> The table has 450 entries and only three fileds, systemname, OS and
> release.
>
> Thanks in advance for any help.
>
> Ian
>

AddThis Social Bookmark Button