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. Equivalent of the following query without FOR XML PATH

Equivalent of the following query without FOR XML PATH

Scheduled Pinned Locked Moved Database
helpdatabasesalesxmlquestion
6 Posts 2 Posters 8 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.
  • I Offline
    I Offline
    indian143
    wrote on last edited by
    #1

    Hi, What is the equivalent of the following query without the FOR XML PATH, when removed the FOR XML PATH from the query it is giving error, can anybody please help with this regards, thanks in advance buddies.

    SELECT
    vw_OwnerXML5010.Owner,
    vw_OwnerXML5010.Billing_EIN AS TP_EIN,
    vw_OwnerXML5010.TP_Name AS TP_NAME,
    vw_OwnerXML5010.County_Code AS County_Code,
    (
    SELECT
    (
    SELECT
    vw_ServiceFacilityXML5010.Service_Facility_NPI AS "Service_Facility_NPI",
    vw_ServiceFacilityXML5010.County_Owned_Indicator AS "County_Owned_Indicator",
    (
    Select
    vw_ServicesXML5010.Procedure_Code AS "Procedure_Code",
    vw_ServicesXML5010.Modifier1 As "Modifier1",
    vw_ServicesXML5010.Modifier2 AS "Modifier2",
    vw_ServicesXML5010.Modifier3 AS "Modifier3",
    vw_ServicesXML5010.Modifier4 AS "Modifier4",
    vw_ServicesXML5010.From_Date AS "From_Date",
    vw_ServicesXML5010.To_Date AS "To_Date",
    vw_ServicesXML5010.Revenue_Code AS "Revenue_Code",
    vw_ServicesXML5010.Place_Of_Service AS "Place_Of_Service",
    vw_ServicesXML5010.Taxonomy_Code AS "Taxonomy_Code"
    FROM
    vw_ServicesXML5010
    WHERE
    vw_ServiceFacilityXML5010.Service_Facility_NPI = vw_ServicesXML5010.Service_Facility_NPI
    and vw_ServiceFacilityXML5010.County_Code = vw_ServicesXML5010.County_Code
    and vw_ServiceFacilityXML5010.Billing_EIN = vw_ServicesXML5010.Billing_EIN
    -- and vw_ServiceFacilityXML5010.County_Code in ('01', '02')
    -- and vw_ServiceFacilityXML5010.Service_Facility_NPI = '1932328580'
    FOR XML PATH('Service'), TYPE , ELEMENTS XSINIL
    )
    FROM
    vw_ServiceFacilityXML5010
    WHERE
    vw_ServiceFacilityXML5010.County_Code = vw_OwnerXML5010.County_Code
    and vw_ServiceFacilityXML5010.Billing_EIN = vw_OwnerXML5010.Billing_EIN
    -- and vw_ServiceFacilityXML5010.County_Code in ( '01', '02')
    -- and vw_ServicesXML5010.Service_Facility_NPI = '1932328580'
    FOR XML PATH ('TB_SERVICE_FACILITY'), TYPE
    -- ) AS "BILLING_PROVIDERS/TB_BILLING_PROVIDER_FILE/TB_SERVICE_FACILITY"
    --) AS "TB_BILLING_PROVIDER_FILE/TB_SERVICE_FACILITY"
    --) AS "TB_BILLING_PROVIDER_FILE"
    ) FOR XML PATH ('TB_BILLING_PROVIDER_FILE'), TYPE
    )
    FROM
    vw_OwnerXML5010
    -- where vw_OwnerXML5010.County_Code in ('01', '02')
    ORDER BY vw_OwnerXML5010.County_Code
    FOR XML PATH ('TB_TRADING_PARTNER'), root('TB_BILLING_PROVIDER_FILES')

    Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."

    CHill60C 1 Reply Last reply
    0
    • I indian143

      Hi, What is the equivalent of the following query without the FOR XML PATH, when removed the FOR XML PATH from the query it is giving error, can anybody please help with this regards, thanks in advance buddies.

      SELECT
      vw_OwnerXML5010.Owner,
      vw_OwnerXML5010.Billing_EIN AS TP_EIN,
      vw_OwnerXML5010.TP_Name AS TP_NAME,
      vw_OwnerXML5010.County_Code AS County_Code,
      (
      SELECT
      (
      SELECT
      vw_ServiceFacilityXML5010.Service_Facility_NPI AS "Service_Facility_NPI",
      vw_ServiceFacilityXML5010.County_Owned_Indicator AS "County_Owned_Indicator",
      (
      Select
      vw_ServicesXML5010.Procedure_Code AS "Procedure_Code",
      vw_ServicesXML5010.Modifier1 As "Modifier1",
      vw_ServicesXML5010.Modifier2 AS "Modifier2",
      vw_ServicesXML5010.Modifier3 AS "Modifier3",
      vw_ServicesXML5010.Modifier4 AS "Modifier4",
      vw_ServicesXML5010.From_Date AS "From_Date",
      vw_ServicesXML5010.To_Date AS "To_Date",
      vw_ServicesXML5010.Revenue_Code AS "Revenue_Code",
      vw_ServicesXML5010.Place_Of_Service AS "Place_Of_Service",
      vw_ServicesXML5010.Taxonomy_Code AS "Taxonomy_Code"
      FROM
      vw_ServicesXML5010
      WHERE
      vw_ServiceFacilityXML5010.Service_Facility_NPI = vw_ServicesXML5010.Service_Facility_NPI
      and vw_ServiceFacilityXML5010.County_Code = vw_ServicesXML5010.County_Code
      and vw_ServiceFacilityXML5010.Billing_EIN = vw_ServicesXML5010.Billing_EIN
      -- and vw_ServiceFacilityXML5010.County_Code in ('01', '02')
      -- and vw_ServiceFacilityXML5010.Service_Facility_NPI = '1932328580'
      FOR XML PATH('Service'), TYPE , ELEMENTS XSINIL
      )
      FROM
      vw_ServiceFacilityXML5010
      WHERE
      vw_ServiceFacilityXML5010.County_Code = vw_OwnerXML5010.County_Code
      and vw_ServiceFacilityXML5010.Billing_EIN = vw_OwnerXML5010.Billing_EIN
      -- and vw_ServiceFacilityXML5010.County_Code in ( '01', '02')
      -- and vw_ServicesXML5010.Service_Facility_NPI = '1932328580'
      FOR XML PATH ('TB_SERVICE_FACILITY'), TYPE
      -- ) AS "BILLING_PROVIDERS/TB_BILLING_PROVIDER_FILE/TB_SERVICE_FACILITY"
      --) AS "TB_BILLING_PROVIDER_FILE/TB_SERVICE_FACILITY"
      --) AS "TB_BILLING_PROVIDER_FILE"
      ) FOR XML PATH ('TB_BILLING_PROVIDER_FILE'), TYPE
      )
      FROM
      vw_OwnerXML5010
      -- where vw_OwnerXML5010.County_Code in ('01', '02')
      ORDER BY vw_OwnerXML5010.County_Code
      FOR XML PATH ('TB_TRADING_PARTNER'), root('TB_BILLING_PROVIDER_FILES')

      Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."

      CHill60C Offline
      CHill60C Offline
      CHill60
      wrote on last edited by
      #2

      You might get a better response with some sample data and expected results

      I 2 Replies Last reply
      0
      • CHill60C CHill60

        You might get a better response with some sample data and expected results

        I Offline
        I Offline
        indian143
        wrote on last edited by
        #3

        I am having a query on the Production Server, I am getting an xml out of it. For some reason there is a problem in the data that I am getting, some data is missing, but I can't easily compare and see it on the xml file what am I missing and why. It would be easier for me if I put the same Data into Table then I can easily compare what am I missing. Or is there anyway that I can read the Data from xml file and put it into a table? I am trying but I have to create table before it seems, but I want to just import into Table like we do from excel files. Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."

        CHill60C 1 Reply Last reply
        0
        • I indian143

          I am having a query on the Production Server, I am getting an xml out of it. For some reason there is a problem in the data that I am getting, some data is missing, but I can't easily compare and see it on the xml file what am I missing and why. It would be easier for me if I put the same Data into Table then I can easily compare what am I missing. Or is there anyway that I can read the Data from xml file and put it into a table? I am trying but I have to create table before it seems, but I want to just import into Table like we do from excel files. Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."

          CHill60C Offline
          CHill60C Offline
          CHill60
          wrote on last edited by
          #4

          CHill60 wrote:

          You might get a better response with some sample data and expected results

          My comment still stands.

          Indian143 wrote:

          when removed the FOR XML PATH from the query it is giving error

          Are you are expecting us to guess what that error might be? There are plenty of people who would like to help you solve your problem, but you're not giving us much to go on. We do this in our spare time so expecting us to wade through the SQL to try and create some tables to match it so we can see what is being produced so we can work out how to replace the FOR XML and get appropriate results ... would take more time than most of us have available. See Some guidelines for posting questions in the forums[^]

          I 1 Reply Last reply
          0
          • CHill60C CHill60

            CHill60 wrote:

            You might get a better response with some sample data and expected results

            My comment still stands.

            Indian143 wrote:

            when removed the FOR XML PATH from the query it is giving error

            Are you are expecting us to guess what that error might be? There are plenty of people who would like to help you solve your problem, but you're not giving us much to go on. We do this in our spare time so expecting us to wade through the SQL to try and create some tables to match it so we can see what is being produced so we can work out how to replace the FOR XML and get appropriate results ... would take more time than most of us have available. See Some guidelines for posting questions in the forums[^]

            I Offline
            I Offline
            indian143
            wrote on last edited by
            #5

            I can understand sorry my friend, the real data of it is PHI and if I have to enter sample data also its difficult, what I was thinking is, maybe somebody has knowledge of For Xml strongly so that they can convert this query into normal sql query, I didn't think that everybody needs sample data, I am extremely sorry my friend. Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."

            1 Reply Last reply
            0
            • CHill60C CHill60

              You might get a better response with some sample data and expected results

              I Offline
              I Offline
              indian143
              wrote on last edited by
              #6

              I can understand by can you please help me how can I create dummy values for the views vw_ServicesXML5010, vw_ServiceFacilityXML5010, as those views are not fetching any records, the xml is not generating those elements, is it possible to help me in that regards. For example if I don't have any records for the View vw_ServicesXML5010 for that where condition I want to have empty value for the elements Procedure_Code, Modifier1, Modifier2, Modifier3, Modifier4, From_Date, To_Date, Revenue_Code, Place_Of_Service, Taxonomy_Code Same thing applies to the View: vw_ServiceFacilityXML5010, if it doesn't have any records then at least one record set with empty values for the Service_Facility_NPI, County_Owned_Indicator. Can you please help me buddy, thanks in advance. Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."

              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