将 sql 的巨大 xml 保存到网络
save huge xml from sql to web
在 sql 服务器中,我有一个函数可以生成所有产品的复杂 xml 并连接多个表:位置、供应商、订单等。
没问题,它在 68 秒内 运行 生成了大约 450MB。
它应该只在迁移到另一台服务器期间偶尔调用,所以花一些时间并不重要。
我想让这个可以通过网络服务器下载。
我已经在经典中尝试了一些变体 asp:
Response.Buffer = false
set rs=conn.execute("select cast(dbo.exportXML() as varchar(max)) as res")
response.write rs("res")
但我只是得到了一个标准
An error occurred on the server when processing the URL. Please contact the system administrator.
If you are the system administrator please click here to find out more about this error.
不是我常用的自定义 500-errorhandler,所以我不确定如何找到错误。
问题出在response.write rs("res"),如果我只是
temp = rs("res")
脚本 运行s,但没有显示任何原因;如果我那时
response.write temp
我遇到同样的失败。
所以问题就出在写这样一个ling串
我可以直接从tsql保存文件吗? 运行 sql 代理定期提供工作?
试试这个:
Response.ContentType = "text/xml"
rs.CursorLocation = 3
rs.Open "select cast(dbo.exportXML() as varchar(max)) as res",conn
'Persist the Recordset in XML format to the ASP Response object.
'The constant value for adPersistXML is 1.
rs.Save Response, 1
我发现使用Response.Write一次可以写入的数据量似乎有限制。我使用的解决方法是将数据分成这样的块:
Dim Data, Done
Done = False
Do While Not Done
Data = RecordSet(0).GetChunk(8192)
If Not Len(Data) = 0 Then
Response.Write Data
Else
Done = True
End If
Loop
在 sql 服务器中,我有一个函数可以生成所有产品的复杂 xml 并连接多个表:位置、供应商、订单等。
没问题,它在 68 秒内 运行 生成了大约 450MB。 它应该只在迁移到另一台服务器期间偶尔调用,所以花一些时间并不重要。
我想让这个可以通过网络服务器下载。
我已经在经典中尝试了一些变体 asp:
Response.Buffer = false
set rs=conn.execute("select cast(dbo.exportXML() as varchar(max)) as res")
response.write rs("res")
但我只是得到了一个标准
An error occurred on the server when processing the URL. Please contact the system administrator. If you are the system administrator please click here to find out more about this error.
不是我常用的自定义 500-errorhandler,所以我不确定如何找到错误。
问题出在response.write rs("res"),如果我只是
temp = rs("res")
脚本 运行s,但没有显示任何原因;如果我那时
response.write temp
我遇到同样的失败。
所以问题就出在写这样一个ling串
我可以直接从tsql保存文件吗? 运行 sql 代理定期提供工作?
试试这个:
Response.ContentType = "text/xml"
rs.CursorLocation = 3
rs.Open "select cast(dbo.exportXML() as varchar(max)) as res",conn
'Persist the Recordset in XML format to the ASP Response object.
'The constant value for adPersistXML is 1.
rs.Save Response, 1
我发现使用Response.Write一次可以写入的数据量似乎有限制。我使用的解决方法是将数据分成这样的块:
Dim Data, Done
Done = False
Do While Not Done
Data = RecordSet(0).GetChunk(8192)
If Not Len(Data) = 0 Then
Response.Write Data
Else
Done = True
End If
Loop