I have the same problem. The extra CR/LF are added every 2033 characters.
Same problem here. Otherwise it seams to be a great way of retrieving XML data from SQL Server.
Running a Query in QA like: "SELECT * FROM
FOR XML AUTO, ELEMENTS" returns a row for each amount of 2033 characters and therefore per row 2 extra CRLF's.
How to handle this?
# Article
9/8/2002 11:51 PM
Jeff G
There is a nice article on exporting SQL Server Data at http://www.PerfectXML.com/Articles/XML/ExportSQLXML.asp
Check it out!!!
# Working with larger data sets
1/14/2003 2:39 PM
jay w
same problem for me. Found microsoft article here: http://support.microsoft.com/default.aspx?scid=KB;en-us;q275583
Their hack workaround suggestions are a pain. I ended up just building xml tags in the select statement and totally bypassed the SQL FOR XML clause. For example Select '
' FROM table. I then exported the data to a .xml file with the method listed above.
# Error 16805
1/29/2003 10:47 AM
Mike
Should be exactly what I want but get error 16805
'SQL Web Assistant: Could not execute the SQL statement.'
even though I have sa permission and the query is valid.
# Error 16805
2/5/2003 9:06 AM
Nitin Gupta
Mike, I am having the same problem. I used the Web Assistant Wizard and I get the same problem.
Let me know if you get a work around.
Thanks,
Nitin
niting@digitalinfuzion.com
# Error 16805
2/17/2003 6:05 AM
Ruchi
I am also having the same problem. Can anybody help me.
My email id is ruchinarang29@yahoo.co.in.
Thanks,Ruchi
# Working with larger data sets
3/9/2003 10:55 AM
Bryan Avery
Try using
DBCC TRACEON(257)
Works a treat
# Error 16805
3/13/2003 6:13 PM
Kossol
I had this problem when having the webtask run a sproc which itself executed dynamic sql (build a string called @SQL the 'exec (@sql)). I tweaked the sql it was running a bit and got it working but I have no idea why some code works but not others. Hope this gives someone a place to start looking to troubleshoot..
# Error 16805
5/8/2003 9:12 AM
Pam
I am having the same exact problem! I know that it has to be permissions related, another user with supposedly the same permissions is able to run the task and I am not. If anyone has any insight, please let me know. Thanks!
Pam pjlahoud@yahoo.com
# Admin writes to sp_makewebtask
7/23/2003 10:18 AM
Bryan Avery
This function is ok but you need to have admin writes to run sp_makewebtask, is there any other method, my user is IUSR_?????? which has only got execute write
# Admin writes to sp_makewebtask
8/15/2003 8:18 AM
Stuart Roberts
Is there a way to output the data to the xml file but instead of overwriting it append the new data to the end?
# Append File
8/15/2003 8:18 AM
Stuart Roberts
Is there a way to output the data to the xml file but instead of overwriting it append the new data to the end?
# Root Node
10/8/2003 10:09 AM
Drew
You can remove the <root> tag from the template file, and only have
<%begindetail%>
<%insert_data_here%>
<%enddetail%>
in your template file. Works fine!
# Error 16805
10/17/2003 2:57 AM
JRuiz
I had the same problem, because I was used FOR XML RAW, ELEMTS.
But if you use FOR XML RAW the problem disapear.
Sorry, about my poor english.
# re: Is there a way to export XML from SQL using a stored procedure?
1/19/2004 12:49 AM
himanshu
it shows me following error..please help..
ODBC: Msg 0, Level 16, State 1
Cannot load the DLL xpweb70.dll, or one of the DLLs it references. Reason: 126(The specified module could not be found.).
# re: Is there a way to export XML from SQL using a stored procedure?
1/19/2004 7:41 AM
Bryant
Are you using SQL Server 2000?
# re: Is there a way to export XML from SQL using a stored procedure?
2/18/2004 8:25 AM
Mark h
It's OK for a simple XML doc- but who uses a simple XML document? I need it for an XML document where the nodes are not equally nested ie they're not a simple table/field name structure.. :-(
# re: Is there a way to export XML from SQL using a stored procedure?
2/19/2004 1:32 PM
TJ
I am getting
"SQL Web Assistant: Could not open the template file" error the file template file is on my c drive and I am trying to run
sp_makewebtask @outputfile = 'c:\temp\myxmlfile.xml',
@query = 'select * from sysobjects for xml auto',
@templatefile = 'c:\temp\template.tpl'
# re: Is there a way to export XML from SQL using a stored procedure?
2/25/2004 7:20 AM
TR
Regarding the "SQL Web Assistant: Could not open the template file" error:
I think that you created the template file on your local computer and that you have a database server somewhere else. The specified path is on the database server. You probably have to create the template file on the server.
# re: Is there a way to export XML from SQL using a stored procedure?
5/10/2004 2:50 AM
Abhay
Getting the error:Server: 16805
SQL Web Assistant: Could not execute the SQL statement. Any Idea, Help. Thanks Abhay
# re: Is there a way to export XML from SQL using a stored procedure?
5/10/2004 3:50 AM
Abhay
Getting the error:Server: 16805
SQL Web Assistant: Could not execute the SQL statement. Any Idea, Help. Thanks Abhay
# re: Is there a way to export XML from SQL using a stored procedure?
5/12/2004 8:41 PM
Bryant
Does your sql statement run in query analyzer?
# Dreaded 16805 error
5/13/2004 5:52 AM
Todd
I am getting the dreaded error. I am running everything locally
EXEC sp_makewebtask
@outputfile = 'c:\temp\Shippers.xml',
@query = 'SELECT * FROM macl_Directory FOR XML AUTO',
@templatefile ='c:\temp\template.txt'
and still getting the error. I am an admin on the box as well as SQL
help????
# re: Is there a way to export XML from SQL using a stored procedure?
7/22/2004 1:02 AM
sanghamitro Ghosh
u are specifying template file as .TXT
but it should be .tpl
# re: Is there a way to export XML from SQL using a stored procedure?
8/18/2004 8:00 AM
Nat
I'm a bit of a newbie to this, so bear with me...
I need to have a saved stored proc on the server ready to be run via a browser(i know how to that part). The SP will need export a single SQL table to a file so that it can be emailed through to another person and imported into a local database. an xml file would be ideal. Im struggling with coding the stored procedure, specifically that part that will deal with creating the exported file. Can anyone help?
# re: Is there a way to export XML from SQL using a stored procedure?
9/4/2004 1:51 AM
Sanghamitro Ghosh
Please create an web task and execute in sql server to generate the required xml format. Place the output xml format in the location required.
The location of the XML out put file shld be specified in the Web task script. Its simple
try out :)
# re: Is there a way to export XML from SQL using a stored procedure?
9/8/2004 9:19 AM
Erik McCarty erik@texastar.com
use pubs
create table root ( data char(1) NULL )
execute master..xp_cmdshell 'bcp "select top 10 * from pubs..root right outer join pubs..authors on 1 = 1 for xml auto" queryout \\stagingsql\Prod_bak\CC7335\bcp.xml -T -c -r -t'
<pubs..root>
<pubs..authors au_id="172-32-1176" au_lname="White" au_fname="Johnson" phone="408 496-7223" address="10932 Bigge Rd." city="Menlo Park" state="CA" zip="94025" contract="1"/>
<pubs..authors au_id="213-46-8915" au_lname="Green" au_fname="Marjorie" phone="415 986-7020" address="309 63rd St. #411" city="Oakland" state="CA" zip="94618" contract="1"/>
<pubs..authors au_id="238-95-7766" au_lname="Carson" au_fname="Cheryl" phone="415 548-7723" address="589 Darwin Ln." city="Berkeley" state="CA" zip="94705" contract="1"/>
<pubs..authors au_id="267-41-2394" au_lname="O'Leary" au_fname="Michael" phone="408 286-2428" address="22 Cleveland Av. #14" city="San Jose" state="CA" zip="95128" contract="1"/>
<pubs..authors au_id="274-80-9391" au_lname="Straight" au_fname="Dean" phone="415 834-2919" address="5420 College Av." city="Oakland" state="CA" zip="94609" contract="1"/>
<pubs..authors au_id="341-22-1782" au_lname="Smith" au_fname="Meander" phone="913 843-0462" address="10 Mississippi Dr." city="Lawrence" state="KS" zip="66044" contract="0"/>
<pubs..authors au_id="409-56-7008"
# To all the have error on execution
10/8/2004 2:14 PM
Greg Grater
I had the same problem with my template file. First, make sure the template file ends in .tpl (suggested above). Second, make sure that the account SQL Server runs under has read\write access to that file. Remember, you're executing the stored procedure from SQL server which runs under a different account than you do personally.
# re: Is there a way to export XML from SQL using a stored procedure?
12/2/2004 7:38 PM
Colin Sheppard
Has there been any resolution to this problem?:
ODBC: Msg 0, Level 16, State 1
Cannot load the DLL xpweb70.dll, or one of the DLLs it references. Reason: 126(The specified module could not be found.).
# re: Is there a way to export XML from SQL using a stored procedure?
12/30/2004 10:04 AM
Sebastián Rivero
Can I make with that tool something like the following sample?:
<root>
<group titulo="group1">
<sintesis>XXXX</sintesis>
<notes>
<note>Note1</note>
<note>Note2</note>
<note>Note3</note>
</notes>
</group>
<group titulo="group2">
<sintesis>YYYY</sintesis>
<notes>
<note>Note1</note>
<note>Note2</note>
<note>Note3</note>
</notes>
</group>
</root>
# re: Is there a way to export XML from SQL using a stored procedure?
12/30/2004 11:11 AM
Sebastián Rivero
Can I make with that tool something like the following sample?:
<root>
<group titulo="group1">
<sintesis>XXXX</sintesis>
<notes>
<note>Note1</note>
<note>Note2</note>
<note>Note3</note>
</notes>
</group>
<group titulo="group2">
<sintesis>YYYY</sintesis>
<notes>
<note>Note1</note>
<note>Note2</note>
<note>Note3</note>
</notes>
</group>
</root>
# re: Is there a way to export XML from SQL using a stored procedure?
2/18/2005 11:48 AM
Meher
Is there any function that could filter the invalid characterfrom a text when it generates an XML file?
I get a message in IE when it tried to parse the XML generated:
"A name contained an invalid character"
# re: Working with larger data sets
3/29/2005 11:47 AM
Soumen
If i use DBCC TRACEON(257) just before the SELECT statement, i still get line breaks at line number 87, then 174 (which is twice of 87), etc. So DBCC TRACEON(257) is not working completely well.
# re: Is there a way to export XML from SQL using a stored procedure?
4/1/2005 4:41 AM
Ken
This snippet of code is a suggestion on exporting the XML data, then
sending that data via email.
Basically, it uses BCP (BulkCopy program) to execute the stored procedure
that creates the XML data, creates a unique file name to export the data to,
then sends the XML data file as an attachment via email.
I got this idea from http://www.sqlteam.com/item.asp?ItemID=4722
DECLARE @CurrentDate AS datetime
DECLARE @YYYYMMDD AS varchar(10)
DECLARE @HHMMSS AS varchar(12)
DECLARE @BasePath AS varchar(255)
DECLARE @FileName AS varchar(500)
DECLARE @bcpCommand AS varchar(1000)
DECLARE @spParm AS varchar(10)
DECLARE @subjectText AS varchar(255)
DECLARE @CleanUpFile AS varchar(555)
-- This is a parm to the stp_SOXMLAccountProfile stored procedure.
-- stp_SOXMLAccountProfile is a stored procedure that creates the well-formed
-- XML document. If anyone would like to
-- see that code, I'll check this posting
-- often to see if it's requested.
-- This would either be passed in as a parameter, or retrieved
-- from a data table
SET @spParm = '999999'
-- Create the date and time portion of the file name we're going
-- to export to.
SET @CurrentDate = GETDATE()
SET @YYYYMMDD = REPLACE(CONVERT(char(10), @CurrentDate, 111), '/', '-')
SET @HHMMSS = REPLACE( CONVERT(char(12), @CurrentDate, 114) ,':', '-')
-- Construct the unique filename we're going to export to.
SET @BasePath = (SELECT DataValue FROM ControlTable
WHERE Module = 'so_xml_accountprofile'
AND Variable = 'basepath')
SET @FileName = @BasePath + 'SO_XML_AP_' + @spParm + '_' +
@YYYYMMDD + '-' + @HHMMSS + '.xml'
-- Create the bulkcopy command we want to execute
SET @bcpCommand = 'bcp "EXEC stp_SOXMLAccountProfile ' + CHAR(39) + @spPar
# re: Is there a way to export XML from SQL using a stored procedure?
4/1/2005 4:44 AM
Ken
Part 2 of above code
(Cutoff by submit process)
-- Create the bulkcopy command we want to execute
SET @bcpCommand = 'bcp "EXEC stp_SOXMLAccountProfile ' + CHAR(39) + @spParm +
CHAR(39) + '" queryout "' + @FileName + '" -S ' + @@SERVERNAME +
' -U youruserid -P yourpswd -f ' + CHAR(34) + @BasePath +
'bcp_SOXMLAccountProfile.fmt' + CHAR(34)
-- Now execute the bulkcopy command
EXEC master..xp_cmdshell @bcpCommand
-- Email stuff
SET @subjectText = 'SalesOutlook Acount Profile Update for ' + @spParm
EXEC master..xp_sendmail @recipients = 'yourname@domain.com',
@message = 'Here is the Sales Outlook data file you requested.',
@attachments = @FileName,
@subject = @subjectText
SET @CleanUpFile = 'DEL ' + @FileName
EXEC master..xp_cmdshell @CleanUpFile
# re: Is there a way to export XML from SQL using a stored procedure?
4/1/2005 6:56 AM
Ken
Part 2 of above code
(Cutoff by submit process)
-- Create the bulkcopy command we want to execute
SET @bcpCommand = 'bcp "EXEC stp_SOXMLAccountProfile ' + CHAR(39) + @spParm +
CHAR(39) + '" queryout "' + @FileName + '" -S ' + @@SERVERNAME +
' -U youruserid -P yourpswd -f ' + CHAR(34) + @BasePath +
'bcp_SOXMLAccountProfile.fmt' + CHAR(34)
-- Now execute the bulkcopy command
EXEC master..xp_cmdshell @bcpCommand
-- Email stuff
SET @subjectText = 'SalesOutlook Acount Profile Update for ' + @spParm
EXEC master..xp_sendmail @recipients = 'yourname@domain.com',
@message = 'Here is the Sales Outlook data file you requested.',
@attachments = @FileName,
@subject = @subjectText
SET @CleanUpFile = 'DEL ' + @FileName
EXEC master..xp_cmdshell @CleanUpFile
# re: Is there a way to export XML from SQL using a stored procedure?
4/21/2005 5:30 PM
Russ
Is there a way to call a stored procedure via HTTP?
i.e. http://lameserver/Northwind/sp_my_stored_procedure¶m1=value1&@param2=value2
Is there something like the above?
# re: Is there a way to export XML from SQL using a stored procedure?
8/19/2005 8:50 PM
mathkids
Yes. Look up the docs on xpath within s2000k there's quite a bit there.
# re: Is there a way to export XML from SQL using a stored procedure?
8/29/2005 7:59 AM
David
Hi Ken:
Would you like to show me the code for stp_SOXMLAccountProfile stored procedure, please?
Thanks
David
# re: Is there a way to export XML from SQL using a stored procedure?
8/29/2005 7:59 AM
David
Hi Ken:
Would you like to show me the code for stp_SOXMLAccountProfile stored procedure, please?
Thanks
David
# re: Is there a way to export XML from SQL using a stored procedure?
9/17/2005 2:02 AM
vipin mukesh
if i execute this qurey
EXEC sp_makewebtask
@outputfile = '\\DEMOSERVER\ShippersXML.xml',
@query = 'SELECT * FROM Shippers FOR XML AUTO',
@templatefile ='\\DEMOSERVER\temp\Shippers.tpl'
then this message has been shown :-
Server: Msg 16821, Level 11, State 1, Procedure sp_makewebtask, Line 125
SQL Web Assistant: Could not open the output file.
demoserver is the server where my sql server run
what should i do plzz help me
# stp_SOXMLAccountProfile
10/17/2005 7:23 AM
achen
Hi Ken:
may I see your stp_SOXMLAccountProfile code ?
thanks !
amy
# Any way to export XML from SQL using the stored procedure sp_makewebtask?
11/9/2005 3:53 PM
sandee
Is there a way to export XML from SQL using a stored procedure sp_MakeWebTask with something like the following sample?:
<root>
<group titulo="group1">
<sintesis>XXXX</sintesis>
<notes>
<note>Note1</note>
<note>Note2</note>
<note>Note3</note>
</notes>
</group>
<group titulo="group2">
<sintesis>YYYY</sintesis>
<notes>
<note>Note1</note>
<note>Note2</note>
<note>Note3</note>
</notes>
</group>
</root>
# Is there a way save an outfile in sp_makewebtask into a different server
11/17/2005 7:58 PM
Mark
if i execute this query i get an error:
SQL Web Assistant: Could not open the output file.
EXEC sp_makewebtask
@outputfile = '\\192.168.0.8\output.asp',
@query = 'select id, name from sample'
@templatefile ='\\192.168.0.1\sample.tpl'
can anyone help?
# re: Is there a way to export XML from SQL using a stored procedure?
11/20/2005 7:26 PM
winson
Appreciate if any one can provide advice on this question by sandee. I'm looking for the same thing
Is there a way to export XML from SQL using a stored procedure sp_MakeWebTask with something like the following sample?:
<root>
<group titulo="group1">
<sintesis>XXXX</sintesis>
<notes>
<note>Note1</note>
<note>Note2</note>
<note>Note3</note>
</notes>
</group>
<group titulo="group2">
<sintesis>YYYY</sintesis>
<notes>
<note>Note1</note>
<note>Note2</note>
<note>Note3</note>
</notes>
</group>
</root>
# re: Is there a way to export XML from SQL using a stored procedure?
2/2/2006 11:03 AM
Essa
Try running the same query as a job. Create a job of the following code.
EXEC sp_makewebtask
@outputfile = '\\192.168.0.8\output.asp',
@query = 'select id, name from sample'
@templatefile ='\\192.168.0.1\sample.tpl'
Thanks
# re: Is there a way to export XML from SQL using a stored procedure?
2/2/2006 11:24 AM
Essa
Try running the same query as a job. Create a job of the following code.
EXEC sp_makewebtask
@outputfile = '\\192.168.0.8\output.asp',
@query = 'select id, name from sample'
@templatefile ='\\192.168.0.1\sample.tpl'
Thanks
# re: Is there a way to export XML from SQL using a stored procedure?
2/28/2006 2:13 PM
Mike
I dont see the solution here. Anyone got the error resolved?
# re: Is there a way to export XML from SQL using a stored procedure?
3/10/2006 8:35 AM
Ivars
How the tpl file should look like?
# re: Is there a way to export XML from SQL using a stored procedure?
3/25/2006 9:39 AM
Joe Doakes
stp_SOXMLAccountProfile
Source code please as promised?
Doakes
# re: Is there a way to export XML from SQL using a stored procedure?
5/5/2006 6:29 AM
r
erwrwe
# re: Is there a way to export XML from SQL using a stored procedure?
8/8/2006 4:52 AM
Wobbly Dave
ODBC: Msg 0, Level 16, State 1 Cannot load the DLL xpweb70.dll
I found that this did work against the default instance, but not the named, quite simply because the xpweb70.dll didnt exist in the MSSQL\Binn directory for the named instances. To cure it I copied the dll out and put it in the Binn directory - the makewebtask procedure then ran just fine
# re: Is there a way to export XML from SQL using a stored procedure?
8/18/2006 3:19 AM
hrubesh
hi have the same problem
Msg 16822, Level 11, State 1, Procedure sp_makewebtask, Line 131
SQL Web Assistant: Could not open the template file.
# re: Is there a way to export XML from SQL using a stored procedure?
8/18/2006 3:20 AM
hrubesh
hi have the same problem
Msg 16822, Level 11, State 1, Procedure sp_makewebtask, Line 131
SQL Web Assistant: Could not open the template file.
# re: Is there a way to export XML from SQL using a stored procedure?
8/29/2006 3:21 AM
jadra
I have a problem with line breaks that sp_MakeWebTask does every 2033 characters. I have to fix them manually everytime, which is pretty annoying.
Some guy on another forum wrote to use DTS, and connect to the database as the OLEDB. I did that, but it did not solve the problem.
If anyone has the solution, i'm all ears...
# re: Is there a way to export XML from SQL using a stored procedure?
8/29/2006 3:49 AM
jadra
Oh, never mind... Silly me....Found the answer.
# Instead of overwriting i want to append the new data to the end
9/1/2006 7:24 AM
Mani
Instead of overwriting i want to append the new data to the end ot the existing file.
please email your answers to mani_sai@yahoo.com
Thanks.
# Instead of overwriting i want to append the new data to the end
9/1/2006 7:26 AM
Mani
Instead of overwriting i want to append the new data to the end ot the existing file.
please email your answers to mani_sai@yahoo.com
Thanks.
# Instead of overwriting i want to append the new data to the end
9/1/2006 7:30 AM
Mani
Instead of overwriting i want to append the new data to the end ot the existing file.
please email your answers to mani_sai@yahoo.com
Thanks.
# re: Is there a way to export XML from SQL using a stored procedure?
10/20/2006 10:00 AM
Khan
I am still getting the "SQL Web Assistant: Could not open the template file." error message. Did anyone figure out why? I just copied the code from the top of this page and tried to execute on a DB that does not have any named instance (in case if that matters).
I tried to put the entire execute command in one line - still no result.
Any help?
# re: Is there a way to export XML from SQL using a stored procedure?
11/15/2006 11:35 AM
Jade S
"SQL Web Assistant: Could not open the template file."
I figured this out. In my case, the SQL Server is on a remote server, and the path the server sees was not valid. Example, I had the template in "C:\TEMP\TEMPLATE.txt", but this file did not exist on the server (it was on my local machine) I ended up sharing my local folder and having the server access the file through UNC names "\\machineName\shareName\TEMPLATE.txt"
# re: Is there a way to export XML from SQL using a stored procedure?
11/15/2006 11:41 AM
Jade S
SQL Web Assistant: Could not open the output file.
Check folder permissions where the file is located. I set Everyone to have full access and that resolved my issue (not recommended, but proof of concept none the less) I can't say for sure what user needs permissions, but this is a start.
# bcp queryout with where clause
12/1/2006 1:48 AM
Harsha
Hi,
I have a problem.
I want to export in csv format with where conditions in the query for an application. I cannot take global temporary table neithe temporary table. Please help
# re: Is there a way to export XML from SQL using a stored procedure?
5/18/2007 7:54 PM
le thannh Diep
Toi la...
# re: Is there a way to export XML from SQL using a stored procedure?
5/18/2007 7:54 PM
le thannh Diep
Toi la...
hom nay troi rat dep.
# Templatefile for 2005
10/19/2007 2:10 AM
Dominik
In SQL 2005 the sp_makewebtask ist depricated but I have to write some version information in the xml file?
I tried some sql tricks, but didn'nt work. I there a possibility to write in the file to append?
reg dominik
# re: Is there a way to export XML from SQL using a stored procedure?
1/8/2009 2:43 AM
uppi
SQL Web Assistant: Could not open the output file.
Even i checked the file permissions and i created the template.tpl in server box(which having sql server2005) i got the above problem ....so if any one help me to solve my problem ..
# re: Is there a way to export XML from SQL using a stored procedure?
1/8/2009 2:46 AM
uppi
SQL Web Assistant: Could not open the output file.
Even i checked the file permissions and i created the template.tpl in server box(which having sql server2005) i got the above problem ....so if any one help me to solve my problem ..
reply me to uppi551@yahoo.co.in
# YnshYyEbgUKLf
10/22/2009 4:02 PM
JXL40
Atlantic Yards project, the largest ever in Brooklyn, to build a basketball arena plus at least 16 high-rise buildings. ,
# YnshYyEbgUKLf
10/22/2009 4:03 PM
JXL40
Atlantic Yards project, the largest ever in Brooklyn, to build a basketball arena plus at least 16 high-rise buildings. ,
# SOLUTION re SQL Web Assistant: Could not open the output file.
6/29/2010 6:42 AM
JD
Hi guys,
The input provided by Jade S gave me final solution: I createed a new folder and gave myself AND the server full access.
Then I executed the
EXEC sp_makewebtask (etc)
It created the file and incl result hoped for.
thx for input.
So many hours spend - and so simple.
br
JD
|

FAQ #29
last updated:
7/3/2002

Survey Results: 106
|
|