Re: run osql.exe from .bat



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
>> > --
>> >
>> >
>>
>>
>
>


.



Relevant Pages

  • Re: Cannot Open SQL Server Table in Access.ADP File.
    ... I dont think that SQL Server will take 'veiw dependencies' into effect; ... Generate Script Wizard did not work on my original database, ... After fixing some of my tables and a few stored procedures and views, ...
    (microsoft.public.access.adp.sqlserver)
  • Re: Enterprise Manager Newbie Question
    ... a SQL backup is not a simple copy of the database files. ... Is it possible to write a script that one could run from a workstation and ...
    (microsoft.public.sqlserver.tools)
  • Re: SQL Security
    ... except I'm having problems making it work in a script. ... ;Set properties of DB objects and open connection to database ... > from Books Online (within the SQL Server program group): ... > communicate with SQL Server. ...
    (microsoft.public.sqlserver.server)
  • Re: Vista hosting XPe tools/db
    ... Are you running this script on the machine that actually has the SQL server ... machine hosting the database. ... i don't know if you can install a second instance of SQL ...
    (microsoft.public.windowsxp.embedded)
  • Re: FORCE DB Corruption
    ... This script from Sharon Dooley should do the trick - be careful with it ... I haven't tried it on SQL 2000, ... /* this script works on a database that is a copy of pubs. ... How can I force a database to become corrupt to a point> that DBCC CHECKDB will report errors? ...
    (microsoft.public.sqlserver.server)

Quantcast