SQL Server Performance

XML EXPLICIT HELP

Discussion in 'General Developer Questions' started by rcatiggay, Apr 17, 2004.

  1. rcatiggay New Member

    I have the following query...


    SELECT 1 AS tag,
    NULL AS parent,
    NULL AS [TARCodeTaxType!1!Override!element],
    NULL AS [TARCodeTaxType!1!TarCode!element],
    NULL AS [TARCodeTaxType!1!TaxType!element],
    NULL AS [TARCodeTaxType!1!ZipTaxType!element],
    NULL AS [TARCodeTaxType!1!ZipTaxCat!element],
    NULL AS [TARCodeTaxType!1!TaxTypeDescription!element]
    UNION ALL
    SELECT DISTINCT 1, 0,
    Override =
    CASE r.override
    WHEN 0 THEN 'N'
    WHEN 1 THEN 'Y'
    ELSE ''
    END,
    r.TarCode As TarCode,
    r.TaxType As TaxType,
    tt.ziptaxtype As ZipTaxType,
    tt.ziptaxcat As ZipTaxCat,
    td.taxtypedescription As TaxTypeDescription

    FROM Tar As t
    JOIN TaxRates As r on t.TarCode = r.TarCode
    JOIN TaxTypes As tt on tt.TaxType = r.TaxType
    JOIN TaxTypeDetail As td on td.TaxType = r.TaxType
    WHERE
    r.Active = 1 AND r.ActionCode <> 'D'
    AND ((20 > 0 AND t.StateFIPS = 20) OR (20 = 0))
    FOR XML EXPLICIT, XMLDATA


    The issue I have is that the first row after the schema is an empty row
    <TARCodeTaxType/>..... Everything after that is fine.

    Any ideas on how to get rid of that first row?
  2. Twan New Member

    Hi ya,

    I think that

    DISTINCT 1, 0,

    should be

    DISTINCT 2, 1

    Currently your second set of records don't have the first record as their parent...?

    Cheers
    Twan

Share This Page