باستخدام XQuery في SQL Server 2005 للحصول على XML الداخلية النص
-
06-07-2019 - |
سؤال
كيف يمكنني اختيار الداخلي نص عقدة XML باستخدام XQuery?
مايكروسوفت الكتب على الانترنت يوضح كيفية retrive سمة أدناه:
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 @Warranty VARCHAR(50)
SET @Warranty = @myDoc.value('(/Root/ProductDescription/Features/Warranty/text())[1]', 'varchar(50)' )
SELECT @Warranty
مارك
لا تنتمي إلى StackOverflow