Re: run osql.exe from .bat
- From: "John Grandy" <johnagrandy-at-yahoo-dot-com>
- Date: Wed, 29 Jun 2005 12:07:01 -0700
Hmmmm ... interesting. Yes, the .sql script I'm running does not ( and is
not intended to ) return a rowset or even a scalar. However, if I run it in
QA, it does return quite a few status lines ( it's a script for database
creation and configuration ). It would be nice to see those status lines in
the output of the .bat file.
"Richard Mueller [MVP]" <rlmueller-NOSPAM@xxxxxxxxxxxxxxxxxxxx> wrote in
message news:OU74ys5dFHA.612@xxxxxxxxxxxxxxxxxxxxxxx
>I see no output (except for the line numbers) if the query returns nothing.
> However, I see results with the following *.sql files:
>
> USE MyDatabase
> GO
> exec sp_helprotect
> GO
>
> Also, with:
>
> USE MyDatabase
> GO
> SELECT MyFieldName FROM dbo.MyTable
> GO
>
> where MyDatabase is the name of a database in my SQL Server, MyTable is a
> table in that database, and MyFieldName is a field in that table. The
> first
> sql runs a system stored procedure. The second outputs the value for one
> field in all rows of the table. If MyTable has no rows, I'll see results
> similar to yours - the output also says "(0 rows affected)". Note, if you
> have an instance name, the bat file must refer to the server\instance. For
> example:
>
> osql -S MyServer\MyInstance -E -i MySQL.sql
>
> You can test your sql in query analyzer to be sure there are results. I
> hope
> this helps.
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab web site - http://www.rlmueller.net
> --
> "John Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
> news:%238BqmB5dFHA.2736@xxxxxxxxxxxxxxxxxxxxxxx
>> I don't see any output. Just line numbers, e.g.
>>
>> 1> 2> 3> 4> 5> 6> 7>
>>
>> The invocation of osql.exe occurs within a .bat file ....
>>
>> I run the .bat file.
>>
>> So I am not directly running osql.exe from a cmd.exe command prompt.
>>
>> The .sql script being run by osql.exe is being run , but something is
>> preventing display of the messages that should appear on the line numbers
> 1>
>> 2> 3> 4> 5> 6> 7> 8> 9> 10>
>>
>>
>>
>> "Richard Mueller [MVP]" <rlmueller-NOSPAM@xxxxxxxxxxxxxxxxxxxx> wrote in
>> message news:u6WtfcqdFHA.2420@xxxxxxxxxxxxxxxxxxxxxxx
>> > John Grandy wrote:
>> >
>> >> Within a batch file (.bat or .cmd), when invoking osql , such as :
>> >>
>> >> osql -S server1 -E -i my-sql-script.sql
>> >>
>> >> How to cause the output of my-sql-script.sql to appear in the output
>> >> of
>> > the
>> >> .bat/.cmd file ? (e.g. in the "Command Prompt" window)
>> >
>> > Hi,
>> >
>> > If you run the batch file at a command prompt, any output will show in
> the
>> > window. Otherwise, use the -o option to specify an output file and
> display
>> > that, perhaps in notepad.
>> >
>> > --
>> > Richard
>> > Microsoft MVP Scripting and ADSI
>> > Hilltop Lab web site - http://www.rlmueller.net
>> > --
>> >
>> >
>>
>>
>
>
.
- References:
- run osql.exe from .bat
- From: John Grandy
- Re: run osql.exe from .bat
- From: Richard Mueller [MVP]
- Re: run osql.exe from .bat
- From: John Grandy
- Re: run osql.exe from .bat
- From: Richard Mueller [MVP]
- run osql.exe from .bat
- Prev by Date: Re: run "net start" remotely
- Next by Date: RE: Enumerating the members of a group and writing it to a text fi
- Previous by thread: Re: run osql.exe from .bat
- Next by thread: Pulling dsescription field from computer object in AD
- Index(es):
Relevant Pages
|