Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL FOR XML issue [modified]

SQL FOR XML issue [modified]

Scheduled Pinned Locked Moved Database
databasexmlhelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DerekFL
    wrote on last edited by
    #1

    Im trying to write a SQL query to populate a XML data feed. I have the query working but they need nodes with prefixes like "media:description" and "live:publocation" I tried SELECT RTRIM(Title) AS Title, [Description], Url AS link, DateCreated AS pubDate, thumbnail AS 'media:thumbnail' FROM dbo.Videos FOR XML PATH('item'), ROOT('media')) but that does not work. Anyone done this before?

    modified on Wednesday, July 9, 2008 2:06 PM

    L 1 Reply Last reply
    0
    • D DerekFL

      Im trying to write a SQL query to populate a XML data feed. I have the query working but they need nodes with prefixes like "media:description" and "live:publocation" I tried SELECT RTRIM(Title) AS Title, [Description], Url AS link, DateCreated AS pubDate, thumbnail AS 'media:thumbnail' FROM dbo.Videos FOR XML PATH('item'), ROOT('media')) but that does not work. Anyone done this before?

      modified on Wednesday, July 9, 2008 2:06 PM

      L Offline
      L Offline
      leoinfo
      wrote on last edited by
      #2

      I'm not sure I understood what you need... Try this:

      WITH XMLNAMESPACES ('uri1' as media, 'uri2' as live)
      SELECT RTRIM(Title) AS 'media:title'
         , [Description]  AS 'media:description'
         , Url            AS 'live:link'
         , DateCreated    AS 'media:pubdate'
         , thumbnail      AS 'media:thumbnail' 
      FROM dbo.Videos FOR XML PATH('item'), ROOT('root')
      
      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups