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.
Author |
Topic |
Cooper_32
Starting Member
3 Posts |
Posted - 2014-05-15 : 10:41:50
|
Hi I am having some problems exporting an XML file via BCP.I have created a stored procedure that creates the XML file, complete with the version declaration <?xml version="1.0" encoding="utf-8" ?>.If I run the procedure manually through sql management studio it correctly creates the file complete with the declaration and saves it to my local path.However when I run it through BCP, it strips off the declaration.Can anyone assist with the correct BCP options, or suggest an alternative.BCP code below************** Set @BcpCommand = 'BCP ' + @BcpSqlQuery + ' queryout "' + @FileLocation+'\'+@FileName + '" -w -S'+@InstanceName+' -Usa -Psa' exec xp_cmdshell @BcpCommand, 'NO_OUTPUT' |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-05-15 : 12:20:36
|
Show us the output of this: PRINT @BcpCommandMaybe you need to add -c and -r\r\n?Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
Cooper_32
Starting Member
3 Posts |
Posted - 2014-05-15 : 14:20:30
|
HiHere is the printout, as requestedBCP exec.Benson.dbo.UDEF_SP_XML_DIM_ORDERS_OUT queryout "C:\Upload\OrderUpload.xml" -w -x -SDM6S9W1\SQL2008R2 -Usa -PsaI should add however, that I posted this to the wrong forum, as it'sSQL 2008 not 2000 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-05-15 : 15:02:35
|
quote: Originally posted by Cooper_32 I should add however, that I posted this to the wrong forum, as it'sSQL 2008 not 2000
I moved the topic to a 2008 forum.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-05-15 : 15:03:41
|
Did you try adding the -c parameter?Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
Cooper_32
Starting Member
3 Posts |
Posted - 2014-05-15 : 16:38:48
|
I did but it hasn't made any difference.Do the options have to be in a set order? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-05-15 : 16:59:00
|
After the file path/name, no.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
|
|
|