🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: bit.databases.mssql-l
1 messages
1 total messages Started by dphillip79 Sat, 14 Jan 2006 02:22
osql batch processing without -i
#36
Author: dphillip79
Date: Sat, 14 Jan 2006 02:22
44 lines
2806 bytes
Hi,
    I have just started using MSSQL and the DOS environment at work.  I have
a lot of experience with Sybase and the UNIX environment, but this is a
whole new ball of wax.
    I'd like to use osql from a batch file to log into the dataserver and
run a fairly long list of SQL and then exit.  I don't want to have a bunch
of SQL files sitting around that I have to use the -i option to run,  and
I'd rather not create temporary SQL files like this.

echo "exec sp_who2" >tmp.sql
echo "select * from....... " >>tmp.sql
osql -E -S <DATASERVER> -n -w999 -i tmp.sql

    I can't use the -Q option, of course because as I said, I'll be writing
quite a few lines of SQL, and it won't all fit on the one line, or at least
it wouldn't be pretty if I did.

    In UNIX, I can execute the following from either the command line or in
a script.

isql -S<DATASERVER> -U<USER> <<-EOF

sp_who
go
select * from .....
go
EOF  --EOF is the isql session terminator exits me back to the command line.

    This behavior does not appear to work with OSQL.  There is a -O option
which help mentions and that talks about disabling the EOF terminator for
batch processing, but I wasn't able to find any usage or examples on the net
where someone is using EOF to terminate their OSQL SQL batch.

This is what help listed.
 [-O use Old ISQL behavior disables the following]
     <EOF> batch processing
     Auto console width scaling
     Wide messages
     default errorlevel is -1 vs 1


    Any help you could offer would be appreciated.  Thanks.

Darren
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads