Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

bcp

2 posts in General Discussion Last posting was on 2010-05-27 05:13:45.0Z
dumbdog Posted on 2010-05-27 03:53:58.0Z
Sender: 184.4bfdebe3.1804289383@sybase.com
From: dumbdog
Newsgroups: sybase.public.ase.general
Subject: bcp
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4bfdecd6.1bd.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 26 May 2010 20:53:58 -0700
X-Trace: forums-1-dub 1274932438 10.22.241.41 (26 May 2010 20:53:58 -0700)
X-Original-Trace: 26 May 2010 20:53:58 -0700, 10.22.241.41
Lines: 10
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:29260
Article PK: 78493

i recall reading 15 bcp have an option to specify the
"select ..." statement or allow me to retrieve the result
set in order or retrieve resultset for a select few
columns(and this is directly from table without using a
view)...

am i dreaming or there is some documented/undocumented
feature of bcp which i can use? i read utility manual, tried
to find the related thread in these forums but cant get a
clue... help pls...


Manish Negandhi Posted on 2010-05-27 05:13:45.0Z
From: "Manish Negandhi" <negandhi.manish.nospam@gmail.com>
Newsgroups: sybase.public.ase.general
References: <4bfdecd6.1bd.1681692777@sybase.com>
Subject: Re: bcp
Lines: 55
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4bfdff89$1@forums-1-dub>
Date: 26 May 2010 22:13:45 -0700
X-Trace: forums-1-dub 1274937225 10.22.241.152 (26 May 2010 22:13:45 -0700)
X-Original-Trace: 26 May 2010 22:13:45 -0700, vip152.sybase.com
X-Authenticated-User: teamsybase
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:29261
Article PK: 78497


<dumbdog> wrote in message news:4bfdecd6.1bd.1681692777@sybase.com...
>i recall reading 15 bcp have an option to specify the
> "select ..." statement or allow me to retrieve the result
> set in order or retrieve resultset for a select few
> columns(and this is directly from table without using a
> view)...
>
> am i dreaming or there is some documented/undocumented
> feature of bcp which i can use? i read utility manual, tried
> to find the related thread in these forums but cant get a
> clue... help pls...

You can use initstring parameter of bcp in order to achive this. Here is the
link explaining the new feature

http://infocenter.sybase.com/help/topic/com.sybase.infocenter.dc20155.1500/html/newfesd/CBACBDBD.htm

The way it works is , sql commands written after initstring will be sent
to ASE before data is transferred. However it will be treated just like
usual command at the session level
and the command will be in effect during the bcp session, therefore actual
bcp out will be executed from the table name given not from select statement
what you execute

for example

bcp master..sysobjects out sysobj2.bcp --initstring "select type from
master..sysobjects where type='U'" -Usa -Sservername -c -P

this command will bcp out all the columns, the select statement will simply
be executed without any effect ,

However you can tweak this a little bit in your case. You can either use
temp table or create view on the fly and execute bcp using the temptable or
view !

(1) using temptable ..
bcp #mytemp out sysobjects_temp.bcp --initstring "select type into #mytemp
from sysobjects where type ='U'" -Usa -Sservername -c

(2) using view
bcp master..sysobjects_view out sysobjview.bcp --initstring "create view
sysobjects_view as select type from sysobjects where
type='U'" -Usa -Sservername -c

-HTH
Manish Negandhi
[TeamSybase]