Click here to Skip to main content
15,885,940 members
Home / Discussions / Database
   

Database

 
AnswerRe: Error in Restoring SQL Server Backup of v 2012 to v 2008 Pin
Victor Nijegorodov1-Jun-18 20:46
Victor Nijegorodov1-Jun-18 20:46 
AnswerRe: Error in Restoring SQL Server Backup of v 2012 to v 2008 Pin
Eddy Vluggen2-Jun-18 0:21
professionalEddy Vluggen2-Jun-18 0:21 
GeneralRe: Error in Restoring SQL Server Backup of v 2012 to v 2008 Pin
indian1434-Jun-18 6:10
indian1434-Jun-18 6:10 
GeneralRe: Error in Restoring SQL Server Backup of v 2012 to v 2008 Pin
Eddy Vluggen4-Jun-18 7:08
professionalEddy Vluggen4-Jun-18 7:08 
QuestionA Control flow Task is appearing in the SSIS Packages xml even after disabling and the deleting it. Pin
indian14331-May-18 13:34
indian14331-May-18 13:34 
QuestionThe following Query is taking too long to execute Pin
indian14330-May-18 13:33
indian14330-May-18 13:33 
SuggestionRe: The following Query is taking too long to execute Pin
CHill6031-May-18 2:53
mveCHill6031-May-18 2:53 
GeneralRe: The following Query is taking too long to execute Pin
indian14331-May-18 13:26
indian14331-May-18 13:26 
GeneralRe: The following Query is taking too long to execute Pin
Eddy Vluggen1-Jun-18 0:10
professionalEddy Vluggen1-Jun-18 0:10 
QuestionGraph Database vs Dimensional Pin
DADom24-May-18 21:32
DADom24-May-18 21:32 
AnswerRe: Graph Database vs Dimensional Pin
Eddy Vluggen26-May-18 2:45
professionalEddy Vluggen26-May-18 2:45 
GeneralRe: Graph Database vs Dimensional Pin
John 1356415428-Jun-18 9:07
John 1356415428-Jun-18 9:07 
GeneralRe: Graph Database vs Dimensional Pin
Eddy Vluggen28-Jun-18 9:19
professionalEddy Vluggen28-Jun-18 9:19 
QuestionHow to create a insert trigger on just one table? Pin
Member23621-May-18 23:02
Member23621-May-18 23:02 
QuestionRe: How to create a insert trigger on just one table? Pin
CHill6022-May-18 1:34
mveCHill6022-May-18 1:34 
AnswerRe: How to create a insert trigger on just one table? Pin
Richard Deeming22-May-18 2:30
mveRichard Deeming22-May-18 2:30 
AnswerRe: How to create a insert trigger on just one table? Pin
Mycroft Holmes22-May-18 14:09
professionalMycroft Holmes22-May-18 14:09 
GeneralRe: How to create a insert trigger on just one table? Pin
CHill6022-May-18 22:56
mveCHill6022-May-18 22:56 
GeneralRe: How to create a insert trigger on just one table? Pin
Mycroft Holmes23-May-18 13:20
professionalMycroft Holmes23-May-18 13:20 
GeneralRe: How to create a insert trigger on just one table? Pin
Member23622-May-18 23:04
Member23622-May-18 23:04 
GeneralRe: How to create a insert trigger on just one table? Pin
Mycroft Holmes23-May-18 13:23
professionalMycroft Holmes23-May-18 13:23 
QuestionFOR XML PATH is not creating Child elements if they are coming with null values Pin
indian14316-May-18 12:39
indian14316-May-18 12:39 
Hi,

I have a query that is using FOR XML PATH, when the child elements has values then its giving the Child elements, but when there are no values coming out of query for the Child elements, its finishing the X-path by putting and end tag (\), but I want the all the elements to be created if there are values are not, it doesn't have to repeat the elements as if there are values but at least one occurrence has to be there even if there are values or don't have values.
Below are the example for it.
Case 1 is the file that it is creating with all the values and elements, there are elements that are repeated I am not putting all that xml here to reduce the size, but I want to create all the elements of the xml even if there are values or no values at least one occurrence.
<TB_BILLING_PROVIDER_FILES>
    <TB_TRADING_PARTNER>
        <Owner>DMH</Owner>
        <TP_EIN>9xxxxxxx1</TP_EIN>
        <TP_NAME>Alameda</TP_NAME>
        <County_Code>01</County_Code>
        <TB_BILLING_PROVIDER_FILE>
            <TB_SERVICE_FACILITY>
                <Service_Facility_NPI>xxxxxxxx7</Service_Facility_NPI>
                <County_Owned_Indicator>true</County_Owned_Indicator>
                <Service xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                    <Procedure_Code>Hxxxxx</Procedure_Code>
                    <Modifier1>HE</Modifier1>
                    <Modifier2>TG</Modifier2>
                    <Modifier3/>
                    <Modifier4/>
                    <From_Date>19811201</From_Date>
                    <To_Date>20030623</To_Date>
                    <Revenue_Code/>
                    <Place_Of_Service/>
                    <Taxonomy_Code/>
                </Service>
            </TB_SERVICE_FACILITY>
        </TB_BILLING_PROVIDER_FILE>
    </TB_TRADING_PARTNER>
</TB_BILLING_PROVIDER_FILES>

The Case 2 xml is as below:
<TB_BILLING_PROVIDER_FILES>
  <TB_TRADING_PARTNER>
    <Owner>DMH</Owner>
    <TP_EIN>xxxxxxxxx</TP_EIN>
    <TP_NAME>Alameda</TP_NAME>
    <County_Code>01</County_Code>
    <TB_BILLING_PROVIDER_FILE/>
  </TB_TRADING_PARTNER>
</TB_BILLING_PROVIDER_FILES>

The sql script for the case 1 is:
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')

The sql script for the case 2 is:
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 
    dbo.vw_SDMCPhaseTwoParentLevelXML 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')

I am not understanding how are these two different, I just want to create the complete xml at least with one occurrence of all the elements, can anybody please help me, any help a suggestion a link or code snippet, anything helps. Thanks in advance buddies.

Thanks,

Abdul Aleem

"There is already enough hatred in the world lets spread love, compassion and affection."
AnswerRe: FOR XML PATH is not creating Child elements if they are coming with null values Pin
CHill6022-May-18 1:32
mveCHill6022-May-18 1:32 
QuestionEquivalent of the following query without FOR XML PATH Pin
indian14314-May-18 12:03
indian14314-May-18 12:03 
SuggestionRe: Equivalent of the following query without FOR XML PATH Pin
CHill6015-May-18 0:11
mveCHill6015-May-18 0:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.