Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 如何在SQL 2000中的NTEXT查询结果上使用sp_xml_preparedDocument?_Sql Server_Xml_Sql Server 2000_Types_Sqlxml - Fatal编程技术网

Sql server 如何在SQL 2000中的NTEXT查询结果上使用sp_xml_preparedDocument?

Sql server 如何在SQL 2000中的NTEXT查询结果上使用sp_xml_preparedDocument?,sql-server,xml,sql-server-2000,types,sqlxml,Sql Server,Xml,Sql Server 2000,Types,Sqlxml,我知道NTEXT正在消失,这里有更大的最佳实践问题(比如将XML存储在NTEXT列中),但我有一个包含XML的表,需要从中提取属性值。使用sp_xml_preparedocument应该很容易做到这一点,但由于您不能声明NTEXT类型的局部变量,并且我也不知道如何使用表达式来指定传递给函数的xml文本,因此这一点变得更加棘手。由于XML或VARCHAR(MAX)数据类型,我可以在SQL2005中这样做,但对于SQL2000我可以做什么呢 DECLARE @XmlHandle int DECLAR

我知道NTEXT正在消失,这里有更大的最佳实践问题(比如将XML存储在NTEXT列中),但我有一个包含XML的表,需要从中提取属性值。使用sp_xml_preparedocument应该很容易做到这一点,但由于您不能声明NTEXT类型的局部变量,并且我也不知道如何使用表达式来指定传递给函数的xml文本,因此这一点变得更加棘手。由于XML或VARCHAR(MAX)数据类型,我可以在SQL2005中这样做,但对于SQL2000我可以做什么呢

DECLARE @XmlHandle int
DECLARE @ProfileXml xml
SELECT @ProfileXml = ProfileXml FROM ImportProfile WHERE ProfileId = 1

EXEC sp_xml_preparedocument @XmlHandle output, @ProfileXml

-- Pluck the Folder TemplateId out of the FldTemplateId XML attribute.
SELECT FolderTemplateId
FROM OPENXML( @XmlHandle, '/ImportProfile', 1)
WITH( 
FolderTemplateId int '@FldTemplateId' )

EXEC sp_xml_removedocument @XmlHandle
对于SQL2000,我唯一能想到的就是使用varchar(8000)。真的没有办法使用下面这样的表达式吗

EXEC sp_xml_preparedocument @XmlHandle output, (SELECT ProfileXml FROM ImportProfile WHERE ProfileId = 1)

好问题。。但没有解决办法

想法:

  • 不能在UDF中包装SELECT调用(创建一种虚拟的ntext局部变量)
  • 无法将
    sp\u xml\u preparedocument
    调用包装在标量UDF中(用于SELECT),因为无法调用扩展存储过程
  • 您无法连接调用以动态运行,因为您将遇到字符串限制和scop问题
  • 使用OPENQUERY的自调用也是如此
  • textptr+READTEXT不能作为参数添加到
    sp\u xml\u preparedocument

那么为什么
sp\u xml\u preparedocument
将ntext作为一种数据类型呢?

您也可以传递varchar、char、text等。所以我不会因此责备sp\u xml\u preparedocument。我尝试在另一个存储过程中包装sp_xml_preparedocument,但遇到了同样的问题,即无法使用表达式将ntext参数获取到包装过程中。