|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to retrive rows from MS SQL server from batch scriptFrom 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 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 > 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 > > > > > 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. -- Show quoteArnie Rowland, Ph.D. Westwood Consulting, Inc Most good judgment comes from experience. Most experience comes from bad judgment. - Anonymous "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 >
Other interesting topics
|
|||||||||||||||||||||||