Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.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 在SQLServer2005中使用XQuery获取XML内部文本_Sql Server_Xml_Tsql_Xquery - Fatal编程技术网

Sql server 在SQLServer2005中使用XQuery获取XML内部文本

Sql server 在SQLServer2005中使用XQuery获取XML内部文本,sql-server,xml,tsql,xquery,Sql Server,Xml,Tsql,Xquery,如何使用XQuery选择XML节点的内部文本 Microsoft联机丛书显示了如何检索以下属性: DECLARE @myDoc xml DECLARE @ProdID int SET @myDoc = '<Root> <ProductDescription ProductID="1" ProductName="Road Bike"> <Features> <Warranty>1 year parts and labor</Warranty

如何使用XQuery选择XML节点的内部文本

Microsoft联机丛书显示了如何检索以下属性:

DECLARE @myDoc xml
DECLARE @ProdID int
SET @myDoc = '<Root>
<ProductDescription ProductID="1" ProductName="Road Bike">
<Features>
  <Warranty>1 year parts and labor</Warranty>
  <Maintenance>3 year parts and labor extended maintenance is available</Maintenance>
</Features>
</ProductDescription>
</Root>'

SET @ProdID =  @myDoc.value('(/Root/ProductDescription/@ProductID)[1]', 'int' )
SELECT @ProdID
DECLARE@mydocxml
声明@ProdID int
设置@myDoc=
1年零件和劳动力
可提供3年零件和人工延长维护
'
SET@ProdID=@myDoc.value('(/Root/ProductDescription/@ProductID)[1],'int')
选择@ProdID
如何获取保修节点的内部文本值?

类似以下内容:

DECLARE @Warranty VARCHAR(50)

SET @Warranty = @myDoc.value('(/Root/ProductDescription/Features/Warranty/text())[1]', 'varchar(50)' )

SELECT @Warranty
马克

类似这样的东西:

DECLARE @Warranty VARCHAR(50)

SET @Warranty = @myDoc.value('(/Root/ProductDescription/Features/Warranty/text())[1]', 'varchar(50)' )

SELECT @Warranty
马克