Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. "really a nice solution file"
  2.  
  3. <Section xml:space="aligned" Paste="False" xmlns="http://schemas.microsoft.com">
  4. <Para FontSize="11" FontWeight="Normal" FontStyle="Normal" TextAlignment="Left">
  5. <Data Text="really a nice solution, but i have an other issue that want to create its xml file" />
  6. </Para>
  7. </Section>
  8.  
  9. <Section xml:space="aligned" Paste="False" xmlns="http://schemas.microsoft.com">
  10. <Para FontSize="11" FontWeight="Normal" FontStyle="Normal" TextAlignment="Left">
  11. <Data Text="really a nice solution file" />
  12. </Para>
  13. </Section>
  14.  
  15. ID Name XMLContent CreatedDate | Modified
  16. --------|------------|------------------|------------------------|-----------------------------------------
  17. 1 | CATEGORYID |<Section xml:space="aligned" Paste="False".| |2011-04-05 12:28:15.030 |
  18. 2 | 114 |<Section xml:space="aligned" Paste="False".|2011-04-05 12:28:15.030 |
  19.  
  20. 1 |really a nice solution, but i have an other issue that want to create its xml file|
  21. 2 |really a nice solution, |
  22.  
  23. DECLARE @xmltbl TABLE (ID INT, XmlData XML)
  24.  
  25. INSERT INTO @xmltbl(ID, XmlData)
  26. VALUES(1, '<Section xmlns="http://schemas.microsoft.com">
  27. <Para FontSize="11" FontWeight="Normal" FontStyle="Normal" TextAlignment="Left">
  28. <Data Text="really a nice solution, but i have an other issue that want to create its xml file" /></Para></Section>'),
  29. (2, '<Section xmlns="http://schemas.microsoft.com">
  30. <Para FontSize="11" FontWeight="Normal" FontStyle="Normal" TextAlignment="Left">
  31. <Data Text="really a nice solution file" /></Para></Section> ');
  32.  
  33. ;WITH XMLNAMESPACES(DEFAULT 'http://schemas.microsoft.com')
  34. SELECT
  35. ID,
  36. DataText = XmlData.value('(/Section/Para/Data/@Text)[1]', 'varchar(200)')
  37. FROM @xmltbl
  38.  
  39. ID DataText
  40. 1 really a nice solution, but i have an other issue that want to create its xml file
  41. 2 really a nice solution file
  42.  
  43. SELECT TOP 5
  44. ID, .....
  45. FROM ......
  46. ORDER BY
  47. -- order by DateAdded descending - giving you the most recent 5 rows
  48. DateAdded DESC
  49.  
  50. ;WITH XMLNAMESPACES(DEFAULT 'http://schemas.microsoft.com')
  51. SELECT TOP 5
  52. ID,
  53. XmlContent.value('(/Section/Para/Data/@Text)[1]', 'varchar(200)')
  54. FROM dbo.YourTableName
  55. ORDER BY CreatedDate DESC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement