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 Query [modified]

SQL For XML Query [modified]

Scheduled Pinned Locked Moved Database
databasetoolsxmlhelp
6 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.
  • G Offline
    G Offline
    GaryWoodfine
    wrote on last edited by
    #1

    Hi Guys I need help with writing the following query
    The Query

    Select  daydesc as description ,Features,        adfull, askprice,   bedrooms as bedroom,rooms,	floorarea as sqm, (pADDRESS1 + ''+  PADDRESS2+ ''+PADDRESS2+         ''+PADDRESS3+ ''+ PADDRESS4) AS ADDRESS  ,directions 		from  dbo.PROPERTY as Property	where property_id = @id 	for xml auto,elements
    

    Which Currently returns this

    < Property>  <description>Space and comfort set the tone of this stylish four bedroomed dormer bungalow on the Moynalty Road just outside the village of Mullagh. Situated just short stroll into Mullagh village and all it's amenities, this proeprty offers a purchaser a spacious family home with open-plan kitchen, dining and living areas. Althrough deceptive from the outside, this property is surprisingly spacious and well-laid out with three bedrooms (one en-suite) and family bathroom on the first floor and a very useful double bedroom with adjacent guest w.c, large sitting room, kitchen/dining, separate living/dining and utility room on the ground floor. Viewing by appointment with the Auctioneers is highly recommended.</description>  <features>Deceptively spacious family home		Quality cream fitted kitchen			Two fine reception rooms 			Slate-tiled kitchen/dining room			Television points in all rooms			Just a short stroll or minutes drive from the village of Mullagh		Close to local Primary SchoolClose to shops, school, church, hotel, playgroup etc.On bus route to secondary schools</features>  <askprice>3.7000000e+005</askprice>  <bedroom>4</bedroom>  <rooms>Entrance Hall (5.38m x 1.78m)Guest W.C. (2.39m x 1.40m)Bedroom (4.35m x 2.51m)Sitting Room (5.98m x 3.62m)Kitchen/Dining Room (8.22m x 3.68m)Utility Room (2.84m x 2.42m)Dining/Living Room (5.38m x 2.84m)Landing ()Bedroom (5.16m x 2.38m)En-Suite Shower Room (1.92m x 1.87m)Bedroom (4.91m x 2.83m)Bedroom (4.17m x 2.88m)Family Bathroom (3.44m x 2.19m)</rooms>  <sqm>166</sqm>  <directions>From Kells, travel about 4.5  miles into Moynalty village, taking left at the RC church and travel almost two miles.  The property is just outside the village of Mullagh on the right hand side.</directions></Property>
    

    It works as expected However, what I would like to achieve is that within the Feat

    C 1 Reply Last reply
    0
    • G GaryWoodfine

      Hi Guys I need help with writing the following query
      The Query

      Select  daydesc as description ,Features,        adfull, askprice,   bedrooms as bedroom,rooms,	floorarea as sqm, (pADDRESS1 + ''+  PADDRESS2+ ''+PADDRESS2+         ''+PADDRESS3+ ''+ PADDRESS4) AS ADDRESS  ,directions 		from  dbo.PROPERTY as Property	where property_id = @id 	for xml auto,elements
      

      Which Currently returns this

      < Property>  <description>Space and comfort set the tone of this stylish four bedroomed dormer bungalow on the Moynalty Road just outside the village of Mullagh. Situated just short stroll into Mullagh village and all it's amenities, this proeprty offers a purchaser a spacious family home with open-plan kitchen, dining and living areas. Althrough deceptive from the outside, this property is surprisingly spacious and well-laid out with three bedrooms (one en-suite) and family bathroom on the first floor and a very useful double bedroom with adjacent guest w.c, large sitting room, kitchen/dining, separate living/dining and utility room on the ground floor. Viewing by appointment with the Auctioneers is highly recommended.</description>  <features>Deceptively spacious family home		Quality cream fitted kitchen			Two fine reception rooms 			Slate-tiled kitchen/dining room			Television points in all rooms			Just a short stroll or minutes drive from the village of Mullagh		Close to local Primary SchoolClose to shops, school, church, hotel, playgroup etc.On bus route to secondary schools</features>  <askprice>3.7000000e+005</askprice>  <bedroom>4</bedroom>  <rooms>Entrance Hall (5.38m x 1.78m)Guest W.C. (2.39m x 1.40m)Bedroom (4.35m x 2.51m)Sitting Room (5.98m x 3.62m)Kitchen/Dining Room (8.22m x 3.68m)Utility Room (2.84m x 2.42m)Dining/Living Room (5.38m x 2.84m)Landing ()Bedroom (5.16m x 2.38m)En-Suite Shower Room (1.92m x 1.87m)Bedroom (4.91m x 2.83m)Bedroom (4.17m x 2.88m)Family Bathroom (3.44m x 2.19m)</rooms>  <sqm>166</sqm>  <directions>From Kells, travel about 4.5  miles into Moynalty village, taking left at the RC church and travel almost two miles.  The property is just outside the village of Mullagh on the right hand side.</directions></Property>
      

      It works as expected However, what I would like to achieve is that within the Feat

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Some of the fomatting didn't appear to come through - you may like to modify your post. Either remove the HTML from the post and click the "Ignore HTML tags in this message (good for code snippets)" or ensure that all opening angle brackets are properly defined as <


      Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: AJAX, SQL Server, Mock Objects My: Website | Blog | Photos

      G 2 Replies Last reply
      0
      • C Colin Angus Mackay

        Some of the fomatting didn't appear to come through - you may like to modify your post. Either remove the HTML from the post and click the "Ignore HTML tags in this message (good for code snippets)" or ensure that all opening angle brackets are properly defined as <


        Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: AJAX, SQL Server, Mock Objects My: Website | Blog | Photos

        G Offline
        G Offline
        GaryWoodfine
        wrote on last edited by
        #3

        I don't understand, The post seems to be ok on my side?

        Kind Regards, Gary


        My Website || My Blog || My Articles

        C 1 Reply Last reply
        0
        • C Colin Angus Mackay

          Some of the fomatting didn't appear to come through - you may like to modify your post. Either remove the HTML from the post and click the "Ignore HTML tags in this message (good for code snippets)" or ensure that all opening angle brackets are properly defined as <


          Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: AJAX, SQL Server, Mock Objects My: Website | Blog | Photos

          G Offline
          G Offline
          GaryWoodfine
          wrote on last edited by
          #4

          Thanks for your time but I managed to find a solution it goes something like this select daydesc as description , cast('' + replace(cast(Features as varchar(max)), char(13)+char(10), '') + '' as xml) AS Features, adfull, askprice, bedrooms as bedroom,rooms, floorarea as sqm, (pADDRESS1 + ''+ PADDRESS2+ ''+PADDRESS2 + ''+PADDRESS3+ ''+ PADDRESS4) AS ADDRESS ,directions from dbo.PROPERTY as Property where property_id = @id for xml auto,elements

          Kind Regards, Gary


          My Website || My Blog || My Articles

          C 1 Reply Last reply
          0
          • G GaryWoodfine

            I don't understand, The post seems to be ok on my side?

            Kind Regards, Gary


            My Website || My Blog || My Articles

            C Offline
            C Offline
            Colin Angus Mackay
            wrote on last edited by
            #5

            cykophysh39 wrote:

            The post seems to be ok on my side?

            There is a set of pre tags with nothing apparently in between.


            Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: AJAX, SQL Server, Mock Objects My: Website | Blog | Photos

            1 Reply Last reply
            0
            • G GaryWoodfine

              Thanks for your time but I managed to find a solution it goes something like this select daydesc as description , cast('' + replace(cast(Features as varchar(max)), char(13)+char(10), '') + '' as xml) AS Features, adfull, askprice, bedrooms as bedroom,rooms, floorarea as sqm, (pADDRESS1 + ''+ PADDRESS2+ ''+PADDRESS2 + ''+PADDRESS3+ ''+ PADDRESS4) AS ADDRESS ,directions from dbo.PROPERTY as Property where property_id = @id for xml auto,elements

              Kind Regards, Gary


              My Website || My Blog || My Articles

              C Offline
              C Offline
              Colin Angus Mackay
              wrote on last edited by
              #6

              Fair enough. :-D


              Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: AJAX, SQL Server, Mock Objects My: Website | Blog | Photos

              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