🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: bit.databases.mssql-l
Article #36

osql batch processing without -i

#36
From: 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
Technical Details
Message-ID: <v7ednXjSAojH_VXenZ2dnUVZ_smdnZ2d@comcast.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: f6611,e4b0c76e1581ff3a,start
X-Google-Attributes: gidf6611,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail
NNTP-Posting-Date: Fri, 13 Jan 2006 20:22:18 -0600
From: <dphillip79@comcast.net>
Newsgroups: bit.databases.mssql-l
Subject: osql batch processing without -i
Date: Fri, 13 Jan 2006 20:22:01 -0600
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Message-ID: <v7ednXjSAojH_VXenZ2dnUVZ_smdnZ2d@comcast.com>
Lines: 46
NNTP-Posting-Host: 68.45.121.190
X-Trace: sv3-X3X9EdC2xZsddAabmIJD0N6A0kH1Zhozw212IuD0BO8DE8vSTQGwBSESXPfnJngnPBlemKU1z15wivy!MW4paaIchIYiOYKaDIoB3SWQkjexhK78MnwhBo/Ii/zggrmWYVmQNyFtL4LRmmXDMgD8f48FuQ4b!5RNuF7IBKRHwrg==
X-Complaints-To: abuse@comcast.net
X-DMCA-Complaints-To: dmca@comcast.net
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.32