2011-12-11 39 views
3

为什么SQL Azure中不支持SQL OpenXML?以及我们可以在SQL Azure中使用哪些替代方法?最后,SQL OpenXML在即将到来的SQL版本中会被弃用吗?为什么SQL Azure中不支持SQL OpenXML?

+0

使用而是使用SQL Server 2005+本机XML/XQuery方法 - 它们更易于使用并且工作得更好。请参阅[SQL Server中的XQuery简介](http://msdn.microsoft.com/zh-cn/library/ms345122%28v=sql.90%29.aspx)或[SQL Server 2005 XQuery和XML-DML - 部分1](http://www.15seconds.com/issue/050803.htm) –

回答

4
+0

“SQL Azure中的存储过程限制”链接令人惊叹。 –

+0

@ fernando-correia我很感激你看看我的答案(https://stackoverflow.com/a/46413643/908677),并分享你的想法是否OPENXML现在应该在Azure中。谢谢! –

0

这一定是在某些时候发生了变化。它看起来是9.25.2017 openxml在SQL Azure中工作正常。我只是跑下面的例子从https://docs.microsoft.com/en-us/sql/relational-databases/xml/examples-using-openxml在SQL Azure的DB和它产生所示的结果:

DECLARE @DocHandle int 
DECLARE @XmlDocument nvarchar(1000) 
SET @XmlDocument = N'<ROOT> 
<Customer CustomerID="VINET" ContactName="Paul Henriot"> 
    <Order OrderID="10248" CustomerID="VINET" EmployeeID="5" 
      OrderDate="1996-07-04T00:00:00"> 
     <OrderDetail ProductID="11" Quantity="12"/> 
     <OrderDetail ProductID="42" Quantity="10"/> 
    </Order> 
</Customer> 
<Customer CustomerID="LILAS" ContactName="Carlos Gonzlez"> 
    <Order OrderID="10283" CustomerID="LILAS" EmployeeID="3" 
      OrderDate="1996-08-16T00:00:00"> 
     <OrderDetail ProductID="72" Quantity="3"/> 
    </Order> 
</Customer> 
</ROOT>' 
-- Create an internal representation of the XML document. 
EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument 
-- Execute a SELECT statement using OPENXML rowset provider. 
SELECT * 
FROM OPENXML (@DocHandle, '/ROOT/Customer',1) 
     WITH (CustomerID varchar(10), 
      ContactName varchar(20)) 
EXEC sp_xml_removedocument @DocHandle 

输出:

CustomerID ContactName 
VINET Paul Henriot 
LILAS Carlos Gonzlez 

我没有看到OPENXML这里列出:https://docs.microsoft.com/en-us/azure/sql-database/sql-database-transact-sql-information#transact-sql-syntax-not-supported-in-sql-database