fli*_*ubt 5 xml sql-server types sql-server-2000 sqlxml
我知道NTEXT正在消失,这里有更大的最佳实践问题(比如在NTEXT列中存储XML),但我有一个包含XML的表,我需要从中获取属性值.这应该很容易使用sp_xml_preparedocument,但由于你不能声明类型为NTEXT的局部变量而我无法弄清楚如何使用表达式来指定传递给函数的XML文本,因此更加棘手.我可以在SQL 2005中这样做,因为XML或VARCHAR(MAX)数据类型,但我能为SQL 2000做些什么?
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
Run Code Online (Sandbox Code Playgroud)
我能为SQL 2000提出的唯一一件事就是使用varchar(8000).是否真的没有办法使用如下表达式?
EXEC sp_xml_preparedocument @XmlHandle output, (SELECT ProfileXml FROM ImportProfile WHERE ProfileId = 1)
Run Code Online (Sandbox Code Playgroud)
很好的问题..但没有解决方案
思考:
sp_xml_preparedocument调用包装在标量UDF中(在SELECT中使用),因为您无法调用扩展存储过程sp_xml_preparedocument那么为什么sp_xml_preparedocument将ntext作为数据类型呢?