Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 isql

Author  Topic 

JeffT
Posting Yak Master

111 Posts

Posted - 2007-01-31 : 15:19:19
Hi,
I'm running isql from a dos batch file and the isql command is below:

%SQLPath%isql -U%DBUser% -P%DBPswd% -S%SQLServer% -d%Gatewaydb% -iBatchScripts\SQL_Get_Create_Batch.sql -oZ:\mbox\recs\in\create_1.bat -w100 -s; -h

I want the rows from the SELECT statement in my ".sql" file to appear in the output file but what ends up being written to the file is this:

1> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> 17> 18> 19> 20> 21> (14 rows affected)

Not sure what I'm doing wrong.
Thanks,
J


1>

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2007-01-31 : 15:29:15
Add the -n parameter to remove numbering.

And if you are using SQL Server 2000, use osql, not isql, and if you are running SQL Server 2005, use sqlcmd, not isql or osql.
Go to Top of Page

JeffT
Posting Yak Master

111 Posts

Posted - 2007-01-31 : 15:52:24
Thanks snSQL !
J
Go to Top of Page

JeffT
Posting Yak Master

111 Posts

Posted - 2007-01-31 : 16:52:23
OK, I'm using osql now with -n and the numbering is gone but I'm still getting "(14 rows affected)" in the output instead of rows from the table:

%SQLPath%osql -U%DBUser% -P%DBPswd% -S%SQLServer% -d%Gatewaydb% -w100 -s -n; -h -iBatchScripts\SQL_Get_Create_Batch.sql -o Z:\mbox\in\create_1.bat

Thanks,
J




Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2007-01-31 : 17:01:27
Add SET NOCOUNT ON to your script.
Go to Top of Page

JeffT
Posting Yak Master

111 Posts

Posted - 2007-01-31 : 17:18:51
Thanks, that gets rid of the "rows affected" message but now I have an empty output file. What I'm trying to write to the output file are the rows SELECT-ed in my "SQL_Get_Create_Batch.sql" query file.
Thanks,
J
Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2007-01-31 : 17:51:53
What's in your script?
Go to Top of Page

JeffT
Posting Yak Master

111 Posts

Posted - 2007-01-31 : 22:30:02
This is what is in the script file:
CREATE TABLE [#temp_create_batch_jeff] (
[RowID] [int] IDENTITY (0, 1) NOT NULL ,
[id] [int] NULL ,
[record] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[file_auth_nbr] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[receiver] [char] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[batch_seq] [int] NOT NULL ,
[lx_cnt] [int] NOT NULL
) ON [PRIMARY]
insert into #temp_create_batch_jeff
select id, record, file_auth_nbr, receiver, batch_seq,lx_cnt from SybaseHDR_QA.dbo.create_batch_jeff where receiver in
(select receiver from SybaseHDR_QA.dbo.create_batch_jeff where receiver in
(select distinct receiver from SybaseHDR_QA.dbo.create_batch_jeff where lx_cnt > 4999)
group by receiver
having count(receiver) = 2)
exit

Thanks,
J
Go to Top of Page

JeffT
Posting Yak Master

111 Posts

Posted - 2007-01-31 : 23:07:22
Just noticed a dumb mistake. Fixed it, and am now getting the output I wanted with the exception of every other line in the output file being blank. Is there a way to get rid of blank lines ?
Thanks,
J
Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2007-02-01 : 10:34:51
I'm not sure, perhaps try varying the -w parameter value.
Go to Top of Page
   

- Advertisement -