Groups | Blog | Home
all groups > sql server clients > january 2004 >

sql server clients : Osql Help


Andy Svendsen
1/28/2004 11:37:07 AM
You forgot the -n switch, that removes numbering.

osql /Usa /Pngsol -n /ic:\Query.qry /o c:\titles.TXT

--
*******************************************************************
Andy S.
MCSE NT/2000, MCDBA SQL 7/2000
andymcdba1@NOMORESPAM.yahoo.com

Please remove NOMORESPAM before replying.

Always keep your antivirus and Microsoft software
up to date with the latest definitions and product updates.
Be suspicious of every email attachment, I will never send
or post anything other than the text of a http:// link nor
post the link directly to a file for downloading.

This posting is provided "as is" with no warranties
and confers no rights.

*******************************************************************
[quoted text, click to view]

Noorali Issani
1/28/2004 7:04:14 PM
Dear Professional

I have used the following query

osql /U sa /P ngsol /i c:\Query.qry /o c:\titles.TXT


That above query gave me the correct result in titles.Txt file but the
problem is that in the top I have received the following stuff which I wanna
remove it and how can I do this ?


1> 2> 1> 2> 1> 2>



---------------------------------------------------------------------------
---
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------
----------------------------------------------------

What I do ?

Waiting for your reply

Noor

Andy Svendsen
1/29/2004 10:34:48 AM
The only way you can return text without separators is to use a print
statement. Then you can use SET NOCOUNT ON to hide the number of rows
affected. PRINT can be used with local variables, global variables and
text.

Otherwise, the separators are pretty much part of SQL statements. There is
no SET statement I know to turn it off.

--
*******************************************************************
Andy S.
MCSE NT/2000, MCDBA SQL 7/2000
andymcdba1@NOMORESPAM.yahoo.com

Please remove NOMORESPAM before replying.

Always keep your antivirus and Microsoft software
up to date with the latest definitions and product updates.
Be suspicious of every email attachment, I will never send
or post anything other than the text of a http:// link nor
post the link directly to a file for downloading.

This posting is provided "as is" with no warranties
and confers no rights.

*******************************************************************
[quoted text, click to view]

Noorali Issani
1/29/2004 1:04:20 PM
thanks but how I remove this lines

---------------------------------------------------------------------------
---
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------
----------------------------------------------------
Waiting

[quoted text, click to view]

Andy Svendsen
1/29/2004 2:16:32 PM
Nope, no switch I know of to hide lines.

You can use print to return certain variables, but the line separator is
part of the results of a SQL statment. You can turn the count off and the
line numbering off, but that's it.

--
*******************************************************************
Andy S.
MCSE NT/2000, MCDBA SQL 7/2000
andymcdba1@NOMORESPAM.yahoo.com

Please remove NOMORESPAM before replying.

Always keep your antivirus and Microsoft software
up to date with the latest definitions and product updates.
Be suspicious of every email attachment, I will never send
or post anything other than the text of a http:// link nor
post the link directly to a file for downloading.

This posting is provided "as is" with no warranties
and confers no rights.

*******************************************************************
[quoted text, click to view]

Noorali Issani
1/29/2004 8:48:14 PM
Like there is command
osql /Usa /Pngsol -n /ic:\Query.qry /o c:\titles.TXT

what I write for hidding lines.

thanks in advance..

Noor
[quoted text, click to view]

cgross NO[at]SPAM online.microsoft.com
1/30/2004 4:12:50 PM
How about /h-1?

osql /SMyServer\Instance /Q"set nocount on select * from sysobjects where
name = 'sysobjects'" /E /h-1

Also, the lines are dashes which indicate comments, so the fact that they
exist in the output should not prevent that output from being used as input
to another osql command.


Cindy Gross, MCDBA, MCSE
http://cindygross.tripod.com
This posting is provided "AS IS" with no warranties, and confers no rights.
Noorali Issani
1/30/2004 6:59:54 PM
Okie but I just wanna share one thing from you, might be u will help me in
this regard. I wanna take the back up of tables via this procedure and might
be after that I will use this script for restoration purpose so the lines
are creating a problem so please let me know any idea what I have to do for
this...

waiting for your reply

Noor






[quoted text, click to view]

Andy Svendsen
2/2/2004 9:24:17 AM
Thank you Noorali and Cindy, I appreciate it. Should've looked at the
switches more closely. /h-1 will help me too.

--
*******************************************************************
Andy S.
MCSE NT/2000, MCDBA SQL 7/2000
andymcdba1@NOMORESPAM.yahoo.com

Please remove NOMORESPAM before replying.

Always keep your antivirus and Microsoft software
up to date with the latest definitions and product updates.
Be suspicious of every email attachment, I will never send
or post anything other than the text of a http:// link nor
post the link directly to a file for downloading.

This posting is provided "as is" with no warranties
and confers no rights.

*******************************************************************
[quoted text, click to view]

Noorali Issani
2/6/2004 5:09:08 PM
ya that's excellent


[quoted text, click to view]

Noorali Issani
2/7/2004 12:11:31 PM
Solve that problem but now I have one more issue which would be last issue I
think so, the problem is that after executing the osql command the result is
saving into one file like this...

insert into [occupation]
(O_Alias,O_IsActive,O_DMLUserID,O_DmlDate,O_DmlOperation ) values
('Software
Engineer',1,5,getdate(),'C')
insert into [occupation]
(O_Alias,O_IsActive,O_DMLUserID,O_DmlDate,O_DmlOperation ) values
('Administrator',1,5,getdate(),'C')

In the above insert query u are seeing there is space b/w Software Enginner
and when I import that data so it also insert spaces so is it possible while
executing the procedure in the command line so I have removed that space and
result look like that

insert into [occupation]
(O_Alias,O_IsActive,O_DMLUserID,O_DmlDate,O_DmlOperation ) values
('Software Engineer',1,5,getdate(),'C')
insert into [occupation]
(O_Alias,O_IsActive,O_DMLUserID,O_DmlDate,O_DmlOperation ) values
('Administrator',1,5,getdate(),'C')

Is it possible ?

Anxiously waiting for you reply

Noor

[quoted text, click to view]

Noorali Issani
2/9/2004 7:34:25 PM
One more question, I want to append the record into text file instead of
overwritting.. I am using this query, what I write for appending into that
file.

osql /Usa /Pngs -n /ic:\Query.qry /o c:\titles.TXT /h-1

Waiting for your reply

[quoted text, click to view]

Erland Sommarskog
2/9/2004 11:06:05 PM
Noorali Issani (naissani@lycos.co.uk) writes:
[quoted text, click to view]

You can use >> for this. >> is a meta-character in the command-line
mode, so this is not an OSQL option. E.g:

osql /Usa /Pngs -n /ic:\Query.qry /h-1 >> c:\titles.TXT


--
Erland Sommarskog, SQL Server MVP, sommar@algonet.se

Books Online for SQL Server SP3 at
AddThis Social Bookmark Button