Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

iSQL - Blank line at the end of the iSql output file
Hi,
I'm using isql to query data and output the same to a flat file.
The isql has the following command options ' -h-1 -w500 -n -b -s""  '.
In the SQL_CODE, the first two lines before the select statement are
use dbname
set nocount on
go
When I run this, an additional blank line is put into the output file.
Actually, there are two lines after the last result set in the output
file. This file is being fed into another system and the blank line is
causing validation issues.
How can I supress this blank line?

This script is run from windows and the isql is called from a bat
script.
Batch script ...
 ====================
 ====================
==================
....
isql -Uuserid -Ppassword -Sserver -i"%SQL_CODE%"  -h-1 -w500 -n -b -s"" 
IF ERRORLEVEL 0 SET RC=0
IF ERRORLEVEL 1 exit 4
 ====================
 ====================
==================
SQL code ...
 ====================
 ====================
==================
use punclaim
set NOCOUNT ON
GO
select * from XYZ;
GO
 ====================
 ====================
==================

Your help is greatly appreciated.
Yash


Report this thread to moderator Post Follow-up to this message
Old Post
yanakal@gmail.com
09-24-05 01:23 AM


Re: iSQL - Blank line at the end of the iSql output file
(yanakal@gmail.com)  writes:
> I'm using isql to query data and output the same to a flat file.
> The isql has the following command options ' -h-1 -w500 -n -b -s""  '.
> In the SQL_CODE, the first two lines before the select statement are
>     use dbname
>     set nocount on
>     go
> When I run this, an additional blank line is put into the output file.
> Actually, there are two lines after the last result set in the output
> file. This file is being fed into another system and the blank line is
> causing validation issues.
> How can I supress this blank line?

You would have to pipe the output to something that strips the last line.

But is there any special reason you use ISQL and not BCP?



--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp


Report this thread to moderator Post Follow-up to this message
Old Post
Erland Sommarskog
09-24-05 01:23 AM


Re: iSQL - Blank line at the end of the iSql output file
Hi

You may want to try passing this through findstr e.g.

osql -E -d punclaim -ifred.sql  -h-1 -w500 -n -b | findstr /V /r /c:"^$" >
fred.txt

Specifying the -d parameter to osql/isql will remove the need for the USE
statement in your SQL script, alternatively the SQL statements:

SET NOCOUNT ON
select * from punclaim..XYZ

There will still be a final carrage return, but not the blank line.

John

<yanakal@gmail.com> wrote in message
news:1127507732.803909.296490@z14g2000cwz.googlegroups.com...
> Hi,
> I'm using isql to query data and output the same to a flat file.
> The isql has the following command options ' -h-1 -w500 -n -b -s""  '.
> In the SQL_CODE, the first two lines before the select statement are
>    use dbname
>    set nocount on
>    go
> When I run this, an additional blank line is put into the output file.
> Actually, there are two lines after the last result set in the output
> file. This file is being fed into another system and the blank line is
> causing validation issues.
> How can I supress this blank line?
>
> This script is run from windows and the isql is called from a bat
> script.
> Batch script ...
>  ====================
 ====================
==================
> ....
> isql -Uuserid -Ppassword -Sserver -i"%SQL_CODE%"  -h-1 -w500 -n -b -s"" 
> IF ERRORLEVEL 0 SET RC=0
> IF ERRORLEVEL 1 exit 4
>  ====================
 ====================
==================
> SQL code ...
>  ====================
 ====================
==================
> use punclaim
> set NOCOUNT ON
> GO
> select * from XYZ;
> GO
>  ====================
 ====================
==================
>
> Your help is greatly appreciated.
> Yash
>



Report this thread to moderator Post Follow-up to this message
Old Post
John Bell
09-24-05 12:23 PM


Re: iSQL - Blank line at the end of the iSql output file
John, Thank you very much. The solution you suggested worked.

Yash


Report this thread to moderator Post Follow-up to this message
Old Post
yanakal@gmail.com
09-27-05 01:24 AM


Sponsored Links





Last Thread Next Thread
Post New Thread

Microsoft SQL Server forum archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 02:01 PM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006