Use of variables in "FOR XML PATH"

Other than using dynamic sql (which we don't want to use) is there a way to use a variable in For XML Path, e.g.
select
FOR XML PATH (@BookName), ROOT('Book'), TYPE
TIA,
edm2

In terms of general XML design this is poor.  An element is normally a 'thing', and the attributes are normally the properties of that thing.  Therefore in your case you would have a Book property with a 'name' attribute.  It would be impossible
to create an XSD for your xml, and makes it awkward for readers of your xml - how do they know the book name beforehand?  Creating this xml in the normal fashion would also make it easy to create without any messing around ( string manipulation,
other hacks ), eg
DECLARE @BookName NVARCHAR(20) = 'SomeBook'
SELECT
@BookName "@name"
-- Other book attributes
FOR XML PATH ('Book'), ROOT('Books'), TYPE
So now you have a Book item(s) within a Books collection.  Easy!  : )

Similar Messages

  • SSMS 2012:FOR XML PATH Using XPath Node Tests-Columnn name 'test()' contains an invalid XML identifier as required by FOR XML?

    Hi all,
    I am learning XPATH and XQUERY from the Book "Pro T-SQL 2008 Programmer's Guide" written by Michael Coles, (published by apress). I copied the Code Listing 12-8 FOR XML PATH Using XPath Node Tests (listed below) and executed it in my
    SQL Server 2012 Management Studio:
    --Coles12_8.sql // saved in C:/Documemnts/SQL Server Management Studio
    -- Coles Listing 12-8 FOR XML PATH Using XPATH Node Tests
    -- Retrieving Name and E-mail Addresses with FOR XML PATH in AdvantureWorks
    -- 16 March 2015 0935 AM
    USE AdventureWorks;
    GO
    SELECT
    p.NameStyle AS "processing-instruction(nameStyle)",
    p.BusinessEntityID AS "Person/@ID",
    p.ModifiedDate AS "comment()",
    pp.PhoneNumber AS "test()",
    FirstName AS "Person/Name/First",
    MiddleName AS "Person/Name/Middle",
    LastName AS "Person/Name/Last",
    EmailAddress AS "Person/Email"
    FROM Person.Person p
    INNER JOIN Person.EmailAddress e
    ON p.BusinessEntityID = e.BusinessEntityID
    INNER JOIN Person.PersonPhone pp
    ON p.BusinessEntityID = pp.BusinessEntityID
    FOR XML PATH;
    I got the following error message:
    Msg 6850, Level 16, State 1, Line 2
    Column name 'test()' contains an invalid XML identifier as required by FOR XML; '('(0x0028) is the first character at fault.
    I have no ideas why I got this error message.  Please kindly help and advise me how to resolve this error.
    Thanks in advance,  Scott Chang

    Hi Michelle, Thanks for your nice response.
    I corrected the mistake and executed the revised code. It worked nicely.
    I just have one question to ask you about the appearance of the xml output of my Co;les12_8.sql:
    <row>
    <?nameStyle 0?>
    <Person ID="1" />
    <!--2003-02-08T00:00:00-->697-555-0142<Person><Name><First>Ken</First><Middle>J</Middle><Last>Sánchez</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="2" />
    <!--2002-02-24T00:00:00-->819-555-0175<Person><Name><First>Terri</First><Middle>Lee</Middle><Last>Duffy</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="3" />
    <!--2001-12-05T00:00:00-->212-555-0187<Person><Name><First>Roberto</First><Last>Tamburello</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="4" />
    <!--2001-12-29T00:00:00-->612-555-0100<Person><Name><First>Rob</First><Last>Walters</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="5" />
    <!--2002-01-30T00:00:00-->849-555-0139<Person><Name><First>Gail</First><Middle>A</Middle><Last>Erickson</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="6" />
    <!--2002-02-17T00:00:00-->122-555-0189<Person><Name><First>Jossef</First><Middle>H</Middle><Last>Goldberg</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="7" />
    <!--2003-03-05T00:00:00-->181-555-0156<Person><Name><First>Dylan</First><Middle>A</Middle><Last>Miller</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="8" />
    <!--2003-01-23T00:00:00-->815-555-0138<Person><Name><First>Diane</First><Middle>L</Middle><Last>Margheim</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="9" />
    <!--2003-02-10T00:00:00-->185-555-0186<Person><Name><First>Gigi</First><Middle>N</Middle><Last>Matthew</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="10" />
    <!--2003-05-28T00:00:00-->330-555-2568<Person><Name><First>Michael</First><Last>Raheem</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="11" />
    <!--2004-12-29T00:00:00-->719-555-0181<Person><Name><First>Ovidiu</First><Middle>V</Middle><Last>Cracium</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    I feel this xml output is not like the regular xml output.  Do you know why it is diffrent from the regular xml xml output?  Please comment on this matter.
    Thanks,
    Scott Chang
    What do you mean by regular xml document? Are you referring to fact that its missing a root element? if yes it can be added as below
    USE AdventureWorks;
    GO
    SELECT
    p.NameStyle AS "processing-instruction(nameStyle)",
    p.BusinessEntityID AS "Person/@ID",
    p.ModifiedDate AS "comment()",
    pp.PhoneNumber AS "text()",
    FirstName AS "Person/Name/First",
    MiddleName AS "Person/Name/Middle",
    LastName AS "Person/Name/Last",
    EmailAddress AS "Person/Email"
    FROM Person.Person p
    INNER JOIN Person.EmailAddress e
    ON p.BusinessEntityID = e.BusinessEntityID
    INNER JOIN Person.PersonPhone pp
    ON p.BusinessEntityID = pp.BusinessEntityID
    FOR XML PATH('ElementName'),ROOT('RootName');
    replace ElementName and RootName with whatever name you need to set for element as well as the root element
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Generate xml using FOR XML PATH from table with hierarchy

    I need to create xml from a table like:
    EL1 EL2 EL3 Attr01 Attr02 Attr03 Attr04
    E10,    ,    ,a,b,c,d
    E10,E1010,    ,a,b,c,d
    E10,E1010,E101010,a,b,c,d
    E10,E1010,E101020,a,b,c,d
    E10,E1010,E101030,a,b,c,d
    E10,E1020,    ,a,b,c,d
    E10,E1020,E102010,a,b,c,d
    E20,    ,    ,a,b,c,d
    E20,E2010,    ,a,b,c,d
    E20,E2010,E201010,a,b,c,d
    E20,E2020,    ,a,b,c,d
    E20,E2020,E202010,a,b,c,d
    E20,E2020,E202020,a,b,c,d
    The hierarchy is EL1--EL2--EL3, and the 3 columns should be elements of xml;
    The other for columns Attr01,Attr02,Attr03,Attr04 should be attributes of xml;
    The actual table could have more than 500 rows(there are many values for El1,EL2,and EL3). 
    The expected xml should like:
    <root>
      <E10 Attr01="a" Attr02="b" Attr03="c" Attr04="d">
        <E1010 Attr01="a" Attr02="b" Attr03="c" Attr04="d">
          <E101010 Attr01="a" Attr02="b" Attr03="c" Attr04="d" />
          <E101020 Attr01="a" Attr02="b" Attr03="c" Attr04="d" />
          <E101030 Attr01="a" Attr02="b" Attr03="c" Attr04="d" />
        </E1010>
        <E1020 Attr01="a" Attr02="b" Attr03="c" Attr04="d">
          <E102010 Attr01="a" Attr02="b" Attr03="c" Attr04="d" />
        </E1020>
      </E10>
      <E20 Attr01="a" Attr02="b" Attr03="c" Attr04="d">
        <E2010 Attr01="a" Attr02="b" Attr03="c" Attr04="d">
          <E201010 Attr01="a" Attr02="b" Attr03="c" Attr04="d" />
        </E2010>
        <E2020 Attr01="a" Attr02="b" Attr03="c" Attr04="d">
          <E202010 Attr01="a" Attr02="b" Attr03="c" Attr04="d" />
          <E202020 Attr01="a" Attr02="b" Attr03="c" Attr04="d" />
        </E2020>
      </E20>
    </root>
    I create a sample Src table:
    CREATE TABLE Src
    EL1 VARCHAR(10),
    EL2 VARCHAR(10),
    EL3 VARCHAR(10),
    Attr01 VARCHAR(10),
    Attr02 VARCHAR(10),
    Attr03 VARCHAR(10),
    Attr04 VARCHAR(10)
    GO
    INSERT INTO Src
    (EL1,EL2,EL3,Attr01,Attr02,Attr03,Attr04
     SELECT 'E10','','','a','b','c','d'
     UNION SELECT 'E10','E1010','','a','b','c','d'
     UNION SELECT 'E10','E1010','E101010','a','b','c','d'
     UNION SELECT 'E10','E1010','E101020','a','b','c','d'
     UNION SELECT 'E10','E1010','E101030','a','b','c','d'
     UNION SELECT 'E10','E1020','','a','b','c','d'
     UNION SELECT 'E10','E1020','E102010','a','b','c','d'
     UNION SELECT 'E20','','','a','b','c','d'
     UNION SELECT 'E20','E2010','','a','b','c','d'
     UNION SELECT 'E20','E2010','E201010','a','b','c','d'
     UNION SELECT 'E20','E2020','','a','b','c','d'
     UNION SELECT 'E20','E2020','E202010','a','b','c','d'
     UNION SELECT 'E20','E2020','E202020','a','b','c','d'
    GO
    I tried to use FOR XML PATH to generate xml for the sample data. When the records increase to a few hundreds, it's not a good idea.
    Here is my script:
    SELECT
    (SELECT Attr01 AS '@Attr01'
    ,Attr02 AS '@Attr02'
    ,Attr03 AS '@Attr03'
    ,Attr04 AS '@Attr04'
    ,( SELECT
    Attr01 AS '@Attr01'
    ,Attr02 AS '@Attr02'
    ,Attr03 AS '@Attr03'
    ,Attr04 AS '@Attr04'
    ,( SELECT
    Attr01 AS '@Attr01'
    ,Attr02 AS '@Attr02'
    ,Attr03 AS '@Attr03'
    ,Attr04 AS '@Attr04'
    FROM Src
    WHERE EL3 = 'E101010'
    FOR XML PATH('E101010'),TYPE
    ) AS 'node()'
    ,( SELECT
    Attr01 AS '@Attr01'
    ,Attr02 AS '@Attr02'
    ,Attr03 AS '@Attr03'
    ,Attr04 AS '@Attr04'
    FROM Src
    WHERE EL3 = 'E101020'
    FOR XML PATH('E101020'),TYPE
    ) AS 'node()'
    ,( SELECT
    Attr01 AS '@Attr01'
    ,Attr02 AS '@Attr02'
    ,Attr03 AS '@Attr03'
    ,Attr04 AS '@Attr04'
    FROM Src
    WHERE EL3 = 'E101030'
    FOR XML PATH('E101030'),TYPE
    ) AS 'node()'
    FROM Src
    WHERE EL2 = 'E1010' AND (EL1 <>'' AND EL3 ='')
    FOR XML PATH('E1010'),TYPE
    ) AS 'node()'--1010
    ,( SELECT
    Attr01 AS '@Attr01'
    ,Attr02 AS '@Attr02'
    ,Attr03 AS '@Attr03'
    ,Attr04 AS '@Attr04'
    ,( SELECT
    Attr01 AS '@Attr01'
    ,Attr02 AS '@Attr02'
    ,Attr03 AS '@Attr03'
    ,Attr04 AS '@Attr04'
    FROM Src
    WHERE EL3 = 'E102010'
    FOR XML PATH('E102010'),TYPE
    ) AS 'node()'
    FROM Src
    WHERE EL2 = 'E1020' AND (EL1 <>'' AND EL3 ='')
    FOR XML PATH('E1020'),TYPE
    ) AS 'node()'--1020
    FROM Src
    WHERE EL1 = 'E10' AND (EL2 ='' AND EL3 ='')
    FOR XML PATH('E10'),TYPE) 'node()'
    ,(SELECT Attr01 AS '@Attr01'
    ,Attr02 AS '@Attr02'
    ,Attr03 AS '@Attr03'
    ,Attr04 AS '@Attr04'
    ,( SELECT
    Attr01 AS '@Attr01'
    ,Attr02 AS '@Attr02'
    ,Attr03 AS '@Attr03'
    ,Attr04 AS '@Attr04'
    ,( SELECT
    Attr01 AS '@Attr01'
    ,Attr02 AS '@Attr02'
    ,Attr03 AS '@Attr03'
    ,Attr04 AS '@Attr04'
    FROM Src
    WHERE EL3 = 'E201010'
    FOR XML PATH('E201010'),TYPE
    ) AS 'node()'
    FROM Src
    WHERE EL2 = 'E2010' AND (EL1 <>'' AND EL3 ='')
    FOR XML PATH('E2010'),TYPE
    ) AS 'node()'--2010
    ,( SELECT
    Attr01 AS '@Attr01'
    ,Attr02 AS '@Attr02'
    ,Attr03 AS '@Attr03'
    ,Attr04 AS '@Attr04'
    ,( SELECT
    Attr01 AS '@Attr01'
    ,Attr02 AS '@Attr02'
    ,Attr03 AS '@Attr03'
    ,Attr04 AS '@Attr04'
    FROM Src
    WHERE EL3 = 'E202010'
    FOR XML PATH('E202010'),TYPE
    ) AS 'node()'
    ,( SELECT
    Attr01 AS '@Attr01'
    ,Attr02 AS '@Attr02'
    ,Attr03 AS '@Attr03'
    ,Attr04 AS '@Attr04'
    FROM Src
    WHERE EL3 = 'E202020'
    FOR XML PATH('E202020'),TYPE
    ) AS 'node()'
    FROM Src
    WHERE EL2 = 'E2020' AND (EL1 <>'' AND EL3 ='')
    FOR XML PATH('E2020'),TYPE
    FROM Src
    WHERE EL1 = 'E20' AND (EL2 ='' AND EL3 ='')
    FOR XML PATH('E20'),TYPE) AS 'node()'
    FOR XML PATH(''),ROOT('root')
    If I get a few hundreds of rows, how huge the script should be. Does anyone have better solution for this? Thanks.
    Tao

    wBob,
    Thanks! And sorry for late feedback.
    The XSD requires the xml structures like the following
    <Schools>
    <School01>Some school</School01>
    <School02>Some other school</School02>
    </Schools>
    I have to use the number in the element name. 
    Right now I just use the nested FOR XML PATH, although I have to write thousand lines code.
    Thanks anyway.
    Tao
    Tao

  • Biztalk WCF-SQL polling sample using a FOR XML Path

    I've been searching in the web for a sample that uses FOR XML "PATH" to poll the SQL database . The result returned from my query is a parent child data and FOR XML PATH is the best choice to structure it in that way . I guess I'm missing something while
    generating the schemas from this stored procedure.
    I guess Dan Rosanova has touched on this concept (http://social.technet.microsoft.com/wiki/contents/articles/3480.aspx)
    , but its using XML Auto. Again there is no sample available so makes things a bit difficult.
    Can someone point to a sample walkthrough , generating the schemas and then later using it in the application.
    Thanks
    Anthstone

    I used XMLPolling and it worked for me. you can go for XMLPolling. Steps to be followed:
    1) Create the SP which will have the SELECT query similar to below:
    ;WITH XMLNAMESPACES (default 'http://yourcustomnamespace')
     Select * from Employee FOR XML PATH('YourCustomRootNode') 
    2) Create a schema out of the table using the following query
    Select * from Employee for
    xml
    auto,
    xmlschema 
    3) Re-name the root name and namespace as per you mentioned in point#1 (YourCustomRootNode)
    4) Create an Envelope Schema and refer the schema from point#3. Also make a note of the root node name and namespace that we need to specify
    in the admin console.
    5) Assign the Body XPath to debatch. Refer
    this.  Deploy the solution.
    6) In the Admin console, add the Root Node Name and namespace mentioned in point#4 under "XmlStoredProcedureRoodNodeName" and "XmlStoredProcedureRoodNodeNamespace"
    There you go. I did this for debatching. You can do for nomarl batch message instead of Envelope create a normal document schema.
    Thanks
    SKGuru

  • "for XML path "  Oracle equivalent of this SQL expression

    SELECT TheID,
    REPLACE(
    RTRIM(
    SELECT StudentID + ' '
    FROM StudentinSchoolLocation TL
    WHERE (LocationID = Results.LocationID)
    FOR XML PATH ('')
    ) AS StudentIDs,
    What is the equivalent of 'For XML path' used above
    The goal is to get a concatenated list of the group by columns. Like where ever the location is same , get the studentIds and make a comma seperated list of all ids for common location
    Works perfectly in SQL.
    Thank you

    Hi,
    user6287828 wrote:
    The goal is to get a concatenated list of the group by columns. Like where ever the location is same , get the studentIds and make a comma seperated list of all ids for common locationThat's called "String Aggregation"
    [AskTom.oracle.com|http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2196162600402] shows several different ways to do it.
    I recommend the first one, the user-defined function STRAGG, which you can copy from that page.
    On Oracle 10 (and up) you may have a similar function, WM_CONCAT (owned by WMSYS), already installed.
    WM_CONCAT is not documented, so you may not want to use it in your Production applications.
    STRAGG is not so convenient if the order of items in the concatenated string is important.
    In that case, use XMLAGG or SYS_CONNECT_BY_PATH, as shown later in the asktom page.
    MODEL can also do ordered string aggregation.

  • Execute SQL Task - FOR XML PATH query error

    I have the following query
    SELECT pl.Id,
    pl.StartTime,
    pl.EndTime,
    pl.PackageName,
    pl.Computer,
    pl.Operator,
    CASE WHEN (CHARINDEX('stack trace', pl.ErrorDescription) > 0) Then
        SUBSTRING(pl.ErrorDescription, 0, CHARINDEX('stack trace', pl.ErrorDescription))
        ELSE
        pl.ErrorDescription
        END as ErrorDescription
    ISNULL(ErrorFile,'') as ErrorFile,
    'Not Applicable' as SourceSystem
    FROM etl.PackageLog as pl
    WHERE pl.Processed = 0
    ORDER BY pl.StartTime, pl.PackageName
    FOR XML PATH('Row'), ROOT(N'FieldingCounts')
    in a Execute SQL Task and i get the following error:
    [Execute SQL Task] Error: Executing the query "SELECT pl.Id,
    pl.StartTime,
    pl.EndTime,
    pl.Package..." failed with the following error: "An invalid character was found in text content.
    ". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
    The query execute without problem in database and in the ssis package doens't run because of the column
    CASE WHEN (CHARINDEX('stack trace', pl.ErrorDescription) > 0) Then
        SUBSTRING(pl.ErrorDescription, 0, CHARINDEX('stack trace', pl.ErrorDescription))
        ELSE
        pl.ErrorDescription
        END as ErrorDescription
    Any help to overcome the problem?
    Thanks

    Hi,
    It looks like that you must be trying to set the result of the query to some variable from the Execute SQL Task. If yes, make sure that the target variable is of the correct data type where XML string  can fit into. Considering that in SSIS, we have
    some limit for XML strings.
    Please let me know if it doesn't help.
    Thanks,
    Nimit

  • How to feed a query using a variable defined as Replacement Path-Query

    Scenario description : BI NetW 2004S - InfoCube with the following characteristics Customer, OrderDate, OrderYear and the following KeyFigure Number of Pieces.
    Objective: I need a query "QB" that shows how many pieces a set of customers has ordered in the year 2008. The set of customers is defined as all customers that in the previous years (the user can select one or more years) have ordered more than 500 pieces within the same year.
    Implementation: In general terms the idea is to build a query "QB" with the characteristic "Customer"  that is restricted (filtered) using a variable that is fed by another query "QA" (Replacement Path-Query).
    In order to have the selection of customers that for each of previous years (2007, 2006, 2005,...) have ordered more than 500 pieces, in the query "QA":
    - I put OrderYear as filter and defined a variable in order to ask the user which year/s he wants to analyse to define the selection
    - I put Customer and OrderYear in row
    - I put the KeyFigure Number of Pieces in column
    - I've defined the following condition: Number of Pieces > 500 with the option Caracteristic Assignment = All Characteristics in the Drilldown Indipendently
    Now if I run the query "QA" it works correctly showing me all customers that in the selected years have ordered more than 500 pieces within of the same year.
    If I run the query "QB" it shows a correct result only if I enter only one year (for example 2006) in the OrderYear field (coming from the query "QA"); if I enter more than one year (for example 2006 and 2007) the selection of customers showed is not the same defined by the first query "QB": I was expecting to see all customers defined from the first query less all customers that have no ordered any piece in 2008.
    Questions
    1) Why is query "QA" working on a different selection of customers when the user selects more than one year?
    2) Cosidering the scenario and the objective described above do you have any other idea?
    Thanks
    Ciao
    Roberto

    Hi Christophe,
         it's ok for me if I consider the customer only once in the final selection of customers that feeds the final query, this is my objective.
    However as test I've created 2 "input" queries, one related to 2006 and one related to 2007, and then in my destination query I've tried to restrict the customer using 2 variables of type replacement path-query (one attached to the 2006 query and one attached to the 2007 query). Unfortunately when I try to check and save the destination query, Query Designer tells me it is not possible to restrict the characteristic in this way.
    Could you please describe me steps you run in to order to restrict a characteristic using more than one variable of type replacement path-query?
    Thank you in advance for your answer.
    Ciao,
    Roberto

  • How to use environment variables in extension.xml

    Is it possible to use environment variable when specify classpath in extension.xml that is part of one JDev extension?

    Hi Matias,
    Sure, you can use substitute-variables command for this purpose.
    See the example below:
    concat [substitute-variables "${system_property:user.home}" | str] "/.m2/repository"]
    Kind regards,
    Ulyana.

  • Query regarding FOR XML PATH

    I have found a script that contains the following:
    stuff(
    select
    ', ' +
    fielda
    from
    tablea
    for
    xml path (''),
    type).value
    'nvarchar(max)')
    ,1,2,
    anotherfield
    This will concatenate field a and the stuff will remove the leading comma.
    I have amended the script to the following and it still works:
    Stuff(
    select
    ', ' +
    fielda
    from
    tablea
    for
    xml path (''))
    ,1,2,
     Afield,
    Please could somebody tell me why the following has been inserted after the
    for xml path ('')
    section
    type).value
    ('.', 'nvarchar(max)')

    Erland - I just did a quick test. The differences weren't as bad as the subtree estimates would have indicated but they weren't exactly close either. The typed version (on average) took just over twice as long to execute.
    Test conditions were as follows:
    AdventureWorks2012 database 
    On average, the non-typed version executed in ~190 ms and the typed version executes in ~405 ms.
    Test bed was the following:
    @@VERSION = 
    Microsoft SQL Server 2012 - 11.0.2218.0 (X64) 
    Jun 12 2012 13:05:25 
    Copyright (c) Microsoft Corporation
    Developer Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: )
    Hardware = 
    Processor: Core i7-4770K @ 3.50GHz (4 physical cores / 8 logical cores)
    Ram: 16.0 GB @ 2400 MHz
    HD: SSD
    Here are the two test scripts that I used... (each run in it own SSMS tab)
    -- Typed version --
    DECLARE @BegDT DATETIME2(7) = SYSDATETIME()
    SELECT
    sod1.SalesOrderID,
    STUFF((
    SELECT ', ' + CAST(sod2.ProductID AS VARCHAR(8))
    FROM Sales.SalesOrderDetail sod2
    WHERE sod1.SalesOrderID = sod2.SalesOrderID
    FOR XML PATH(''), TYPE).value('.', 'varchar(max)'), 1, 2, '') AS csv
    FROM
    Sales.SalesOrderDetail sod1
    GROUP BY
    sod1.SalesOrderID
    SELECT DATEDIFF(ms, @BegDT, SYSDATETIME()) AS ExecTimeMS
    -- Non-typed version --
    DECLARE @BegDT DATETIME2(7) = SYSDATETIME()
    SELECT
    sod1.SalesOrderID,
    STUFF((
    SELECT ', ' + CAST(sod2.ProductID AS VARCHAR(8))
    FROM Sales.SalesOrderDetail sod2
    WHERE sod1.SalesOrderID = sod2.SalesOrderID
    FOR XML PATH('')), 1, 2, '') AS csv
    FROM
    Sales.SalesOrderDetail sod1
    GROUP BY
    sod1.SalesOrderID
    SELECT DATEDIFF(ms, @BegDT, SYSDATETIME()) AS ExecTimeMS
    If you see holes in my test approach, please let me know.
    Thanks,
    Jason
    Jason Long

  • Java Mapping Using JAXB [Java Arch for XML Binding]

    Hi All,
    Anyone tried using JAXB  [Java Architecture for XML Binding API available with Java WebServices Pack] technique for XML processing in Java Mapping??
    I am facing the following problems..
    1. I am not able to generate namespace while marshalling target XML [In standalone mode and not tried in XI].
    2. What are the jar files we need to import?
       I tried importing the following jar files in XI.
    jaxb-api.jar,jaxb-impl.jar,jaxb-libs.jar,jax-qname.jar,namespace.jar,relaxngDatatype.jar
      and getting some errors while importing these files in XI.
    3. It throws error at runtime [Interface Mapping-Test Tab]
       like Resource not found:javax/xml/bind/Messages_en.properties,javax/xml/bind/Messages_en_US.properties
    4. Even after creating a copy of available file Messages.Properties with name: Messages_en.properties and Messages_en_US.properties.. it is not generating any messages in Target message tab
    Thanks in Advance,
    Ananth Chinnaraj

    Sravya ,
    I have searched wide and far for this, but no success.
    A lot on JAXB XI and Webdynpro, but nothing on JAXB, XI and mappings.
    Could you please post the url here ?
    Thanks and kind regards,
    Jan

  • Does oracle have similar functionality like MsSql "for xml path('')"

    Does oracle have similar build in functionality like MsSql “for xml path(‘’)” , or in another word, it can enforce the result set(multiple rows) into ONE line such kind of presentation way.
    Thanks in advance. Any help would be greatly appreciated.

    Here I would like specify my question mnore clearly,
    CREATE TABLE t(
    line NUMBER(3),
    site VARCHAR2(4),
    phase VARCHAR2(5),
    test VARCHAR2(25));
    INSERT INTO t VALUES (1, '0100', '*','1111111111111111111111111' );
    INSERT INTO t VALUES (2, '0100', '=','2222222222222222222222222' );
    INSERT INTO t VALUES (3, '0100', '=','3333333333333333333333333' );
    INSERT INTO t VALUES (4, '0100', '*','4444444444444444444444444' );
    INSERT INTO t VALUES (5, '0100', '=','5555555555555555555555555' );
    INSERT INTO t VALUES (6, '0200', '*','6666666666666666666666666' );
    Here I want to retrieve the 'line' column information in ONE line way
    select line from t I want the result is like '1,2,3,4,5,6'
    Any generous help would be greatly appreciated!!!

  • Do not use bind variable notations for p_session_id argument...

    Hi there,
    ... in apex_custom_auth.login the Apex doc says. Does anyone know why not?
    LOGIN Procedure
    Also referred to as the "Login API," this procedure performs authentication and session registration.
    p_session_id Current Oracle Application Express session ID.
    Note: Do not use bind variable notations for p_session_id argument.Thanks
    Luis

    I tend to avoid assigning values to bind variables like that - but it may be due to the nature of much of my code residing in PL/SQL packages.
    And due to the strange encounters I have had with this, like your linked discussions, I've tended towards using apex_util instead.
    You may also enjoy this discussion
    http://www.danielmcghan.us/2012/08/implicit-commits-in-apex.html
    Scott

  • Using a Variable to Substitute the path\filename of a Batch file in the Start_Process Command

    I am trying to write a script that will execute a batch file on a remote Windows server.
    This line below is basically what I'm trying to do and it works without error, however I would like to use a variable for the path\filename of the batch file.
    invoke-command -computername QSC-A-ICE01 -scriptblock {Start-Process "\\qsc-a-ice01\D$\Test\RunThis.bat" }
    If I try to use a variable as in this example below I receive the error below. The error seems to indicate it's it expecting a "FilePath" parameter. Is this true? How would I change this script to make it work when substituting a variable.
    $MyProcess =  "\\qsc-a-ice01\D$\Test\RunThis.bat"
    Write-Host $MyProcess
    invoke-command -computername QSC-A-ICE01 -scriptblock {Start-Process "$MyProcess"}
    This is the error text I receive when using a variable:
     PS C:\Windows\system32> D:\Test\ThisWorks.ps1
    \\qsc-a-ice01\D$\Test\RunThis.bat
    Cannot validate argument on parameter 'FilePath'. The argument is null or empty. Supply an argument that is not null or
    empty and then try the command again.
        + CategoryInfo          : InvalidData: (:) [Start-Process], ParameterBindingValidationException
        + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.StartProcessCommand
        + PSComputerName        : QSC-A-ICE01
    PS C:\Windows\system32>

    Mike,
    Thanks for providing the link, it was very informative. The link described how to use the args in a ScriptBlock and provided me with an explaination as to why it works the way it does on a remote server. This is my 1st post to the forum and I don't know
    how the points system works yet.
    I would like to split the points , but I don't see that this is possible.
    You're very welcome, I'm glad that the information was helpful.
    You can mark as many posts as answers as you'd like, there's not a restriction on only having a single answer per thread. You certainly don't have to though, David's answer is more than sufficient to help any future people who find this thread.
    Also, on a side note, you may want to post in the thread below. Posting there will get your account verified so you'll be able to post links and images.
    http://social.technet.microsoft.com/Forums/en-US/200c33c9-abe9-494a-953a-bf53fccb3c76/verify-your-account-11?forum=reportabug
    (Future people - don't use that link.
    Click here and look for the current thread as a sticky.)
    Don't retire TechNet! -
    (Don't give up yet - 12,575+ strong and growing)

  • Variable entry for replacement path

    Hi Guys,
    This is my scenario. I have query A which uses a set of results from query B via replacement path. I have a mandatory variable entry for Query A which I have used also for query B. I was under the impression that when I made a user entry for the variable for query A, that value would be copied over to query B and perform the filtering in Query B too. Is this not the case.
    If I need to perform this operation, i.e use the value that I enter for variable entry in Query A in Query B, how can I do that?
    Thanks,
    Doniv

    Hello Doniv,
    we are using this scenario in our queries too, if we define the same variable in the query A and B,
    this value is used for the selection in the query B.
    Did you tried to search in OSS? (this could be the SAP error)
    Regards,
    Kirill

  • How can I have a use a variable view for a Popover in Xcode Applescript-ObjC?

    I'm adding Popovers to my application, but I have it coming from buttons in different views. One button might be in a Tab-View, and one in the main window. If I specify the wrong view, the Popover is off to the left and down, like the image below:
    Here's my code:
    on OpenPopover_(sender)
            Popover's showRelativeToRect_ofView_preferredEdge_(sender's frame(), MainWindow's contentView(), current application's NSMaxYEdge)
            end OpenPopover_
    How can I use a variable view or not specify the view at all so that the buttons can be in different views without having to use multiple pieces of code, using Applescript-ObjC, Xcode?

    You are using the content view of the entire window instead of whatever view the button is in - the frame rectangles are relative to the view it is in.
    The method parameters are a rectangle that is relative to the view (to position the popover), the view containing the rectangle, and the edge of the rectangle to use.  To position relative to a button, you can get the button's superview (the containing view), for example:
    popover's showRelativeToRect_ofView_preferredEdge_(sender's frame(), sender's superview(), current application's NSMaxYEdge)

Maybe you are looking for

  • How to create a Savepoint in Oracle?

    Hello! How can I create a 'savepoint' in Oracle. Thanks in advance.

  • Need to get the Mail attachment name as it is to the receiver file adapter

    I am doing a Mail to File scenario. I need to get the attachment from the mail and store it on the file server. I am using the PayloadSwap bean in the sender mail adapter. My requirement is to carry forward the attachement name as it is to the receiv

  • Is it possible to configure ERMS in Multi Client environment

    Hi All, I am currently working on a requirement where in we have a single CRM Instance connected to multiple back end ECC Systems. We have a client set up in CRM fore each ECC System. Each ECC System address the requirements specific to a region. Com

  • Making a swf wait until the rest of the HTML page is ready?

    I have a site with a common SWF embedded at the top of each page, and then regurlar graphic/text HTML content below it. I was anticipating that the SWF might have a bit of a delay for it to load, and that the rest of the page would be appearing prett

  • IWeb versus .Mac

    I am looking into purchasing .mac and iLife. On perusing, it seems iLife has iWeb and .Mac is all about interacting with the web. Why purchase both? What are the distinct differences? Anyone? Thanks. Novice to the web using realm, KO