EXEC master..xp_cmdshell 'bcp "SELECT hasta..ar.artnr ,
hasta..ar.artbeskr FROM hasta..ar where hasta..ar.itemstatuscode = 210
FOR XML RAW" queryout "c:\outpath\ups\ups.xml" -T -Sbamse -Usa -P13hla
-c -r'''' -t'''''
this works for me as long as the where clause holds an int datatype,
but if I need to single quote a varchar value such as where
hasta..ar.artnr = '1440' the it fails, how do I "escape" the '1440' ??
Matt
"John Bell" <jbellnewsposts@hotmail.com> wrote in message news:<3f50b7c3$0$10770$afc38c87@news.easynet.co.uk >...
> Hi
>
> This will work.
>
> EXEC master..xp_cmdshell 'bcp "SELECT OrderId, CustomerId FROM
> Northwind..ORDERS where OrderId = 10252 FOR XML RAW" queryout
> "c:\outpath\ups\ups.xml" -T -S Server -c -r'''' -t''''', NO_OUTPUT
>
> You need to specify a fully qualified database name for the table.
> The -r and -t options require values (i.e. empty string)
> NO_OUTPUT will suppress messages (remove for debugging!)
> The directory c:\outpath\ups must exist.
> Using quotes around the filename will help with spaces.
>
> John
>
>
>
> "Matt" <matt@fruitsalad.org> wrote in message
> news:b609190f.0308300552.4a084f5e@posting.google.c om...
> > > http://www.sqlteam.com/Forums/topic.asp?TOPIC_ID=9336
> > >
> > Trying this approach with the following code
> >
> > exec ('master..xp_cmdshell"bcp "SELECT ar.artnr , ar.artbeskr FROM ar
> > where ar.artnr = 1445 FOR XML RAW" queryout c:\outpath\ups\ups.xml
> > -UXXX -PXXX -c -r -t"')
> >
> > gives me the following error
> >
> > Server: Msg 170, Level 15, State 1, Line 1
> > Line 1: Incorrect syntax near ' queryout c:\outpath\ups\ups.xml -Usa
> > -P13hla -c -r -t'.
> >
> >
> > I am using SQL2000 and the bcp serion is 8+
> >
> > Any ideas?
> >
> > Matt