Hi,

I need to use bcp, a command line utility installed with sqlserver, from my
script.
if I issue the following command at the command prompt it works:
bcp "SELECT * FROM pubs..authors" queryout c:\Authors.txt -c -T.
Note that the sql statment is quated.

I tried to use bcp in the same way as I do with other command lines programs
such as:
oShell.Run "cmd /C IPconfig/all > ........" I fell to do so as I do not
know how to address the fact that the sql statment is a string and the
entire parameter passed to the Run method is also a string so there is
actually a string inside a string.



Thanks,
Yaniv

Re: a string within a string by Torgeir

Torgeir
Thu Sep 09 05:04:59 CDT 2004

msnews.microsoft.com wrote:

> Hi,
>
> I need to use bcp, a command line utility installed with sqlserver, from my
> script.
> if I issue the following command at the command prompt it works:
> bcp "SELECT * FROM pubs..authors" queryout c:\Authors.txt -c -T.
> Note that the sql statment is quated.
>
> I tried to use bcp in the same way as I do with other command lines programs
> such as:
> oShell.Run "cmd /C IPconfig/all > ........" I fell to do so as I do not
> know how to address the fact that the sql statment is a string and the
> entire parameter passed to the Run method is also a string so there is
> actually a string inside a string.
Hi

Inside a quoted string, you will need to use two quotes to get
one effective:

oShell.Run "bcp ""SELECT * FROM pubs..authors"" queryout c:\Authors.txt -c -T"


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Re: a string within a string by msnews

msnews
Thu Sep 09 07:13:58 CDT 2004

Works, thank you very much.





"Torgeir Bakken (MVP)" <Torgeir.Bakken-spam@hydro.com> wrote in message
news:eYhNYSllEHA.1936@TK2MSFTNGP12.phx.gbl...
> msnews.microsoft.com wrote:
>
> > Hi,
> >
> > I need to use bcp, a command line utility installed with sqlserver, from
my
> > script.
> > if I issue the following command at the command prompt it works:
> > bcp "SELECT * FROM pubs..authors" queryout c:\Authors.txt -c -T.
> > Note that the sql statment is quated.
> >
> > I tried to use bcp in the same way as I do with other command lines
programs
> > such as:
> > oShell.Run "cmd /C IPconfig/all > ........" I fell to do so as I do not
> > know how to address the fact that the sql statment is a string and the
> > entire parameter passed to the Run method is also a string so there is
> > actually a string inside a string.
> Hi
>
> Inside a quoted string, you will need to use two quotes to get
> one effective:
>
> oShell.Run "bcp ""SELECT * FROM pubs..authors"" queryout
c:\Authors.txt -c -T"
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx