Trying to store result in xml format in variable sql server

i am just trying to compare two xml and try to store the difference into another variable called
@DiffXML but getting error called Incorrect syntax near the keyword 'SET'.
just guide what to fix. thanks
DECLARE @XML1 XML
DECLARE @XML2 XML
DECLARE @DiffXML nvarchar(max)
SET @DiffXML=''
SET @XML1 =
'<NewDataSet>
<Employee>
<EmpID>1005</EmpID>
<Name> keith </Name>
<DOB>12/02/1981</DOB>
<DeptID>ACC001</DeptID>
<Salary>10,500</Salary>
</Employee>
</NewDataSet>'
SET @XML2 =
'<NewDataSet>
<Employee>
<EmpID>1006</EmpID>
<Name> keith </Name>
<DOB>05/02/1981</DOB>
<DeptID>ACC002</DeptID>
<Salary>10,900</Salary>
</Employee>
</NewDataSet>'
;with XML1 as
select T.N.value('local-name(.)', 'nvarchar(100)') as NodeName,
T.N.value('.', 'nvarchar(100)') as Value
from @XML1.nodes('/NewDataSet/Employee/*') as T(N)
XML2 as
select T.N.value('local-name(.)', 'nvarchar(100)') as NodeName,
T.N.value('.', 'nvarchar(100)') as Value
from @XML2.nodes('/NewDataSet/Employee/*') as T(N)
SET @DiffXML=(select * from
select coalesce(XML1.NodeName, XML2.NodeName) as FieldName,
XML1.Value as OldValue,
XML2.Value as NewValue
from XML1
full outer join XML2
on XML1.NodeName = XML2.NodeName
where coalesce(XML1.Value, '') <> coalesce(XML2.Value, '')
) x FOR xml AUTO,elements XSINIL)
print @DiffXML

hey it is solved
i should use select instead of set
SELECT @DiffXML=(select * from
select coalesce(XML1.NodeName, XML2.NodeName) as FieldName,
XML1.Value as OldValue,
XML2.Value as NewValue
from XML1
full outer join XML2
on XML1.NodeName = XML2.NodeName
where coalesce(XML1.Value, '') <> coalesce(XML2.Value, '')
) x FOR xml AUTO,elements XSINIL)
print @DiffXML

Similar Messages

  • XMII Frustration, trying to hold " SAP xMII XML format" in variable

    I have two queries that return the same result (same columns, different rows).  I'm running one or the other based on a condition.  I want to assign the result to something so that I can run a repeater against it after (one of the two) queries has run.
                         Cond   ....      3rd leg(After condition)
                 Query 1    Query 2       Repeater

    Paul,
    If your two queries (different Query Templates?) both return the exact same columns, but just different rows, wouldn't it make more sense to just have a single Query action block instead of a conditional branch?  This way your Repeater logic could just work directly on the single query results and you wouldn't have to map or copy any xml objects around.
    You could use the stringif function in the expression editor to handle the specifics of your current Query1 and Query2, even adjusting the QueryTemplate property of the action block itself if necessary.  The effective use of query parameters and/or the template(s) themselves should make this quite possible and streamlined in your logic flow.
    Regards,
    Jeremy

  • Output query result in XML format

    folks:
    could anybody provide more information
    about how to generate query result in
    xml format? looks like DBXML is for demo only
    and i have heard that PLSQL XML parser is the way to go; so far i have not found
    a sample yet on how to actually
    do the XML generation; if you know more
    about it, please let me know; thanks in
    advance.
    Bill

    Here are some sample apps that might interest you:
    [list]
    [*][url [URL=http://technet.oracle.com/tech/xml/xsql_servlet/index2.htm?Code&files/ffhome.html]The]http://technet.oracle.com/tech/xml/xsql_servlet/index2.htm?Code&files/ffhome.html]The XML Flight Finder
    [*][url [URL=http://technet.oracle.com/sample_code/tech/xml/xmlb2b/doc/xb2bhome.html]B2B]http://technet.oracle.com/sample_code/tech/xml/xmlb2b/doc/xb2bhome.html]B2B with XML
    [list]
    Enjoy,
    -rh

  • Saving the query result in XML format

    Hi All,
    I have a requirement to save the result of a query in XML format on the application server. Can we do this?
    Best Rgds,
    James.

    You can explore the possibility of the execution of query with XMLA:
    Official documentation
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/1d71d190-0201-0010-239a-8b96516bf372
    and a good Blog
    /people/prakash.darji/blog/2006/09/04/work-with-xmla-web-service-for-bi-data-in-external-applications
    The result will be an SOAP message (XML) but also the request could be a SOAP message you can investigate if simulate the request by BW client or server.
    Regards,
    Sergio

  • Returning query results in XML format

    Besides using custom tag library, does anyone know any methods or techniques that i can retrive the query results from database in XML format. for example, i have a table named student in database like this:
    StudentNo  Name   Gender  Degree
    123       Tony    male    B.Comp.Sci.
    456       Tom     male    B.Fiance
    343       Mary    female  B.Accountingso, if i have query select * from table student, i would get someting like the following:
    <row>
    <studentNo>123</studentNo>
    <name>Tony</name>
    <Gender>male</Gender>
    <Degree>B.Comp.Sci</Degree>
    </row>
    <row>
    <studentNo>456</studentNo>
    <name>Tom</name>
    <Gender>male</Gender>
    <Degree>B.Finace</Degree>
    </row>
    The reason i am asking for this is i need query results returned in XML format, so i can wrap XSLT tag around, and apply for HTML, WML, and XHTML template resprectively so i can display them on different terminals. any help is appreciated.

    I have this method in a ResultSetMapper class:
         * Return result sets as an XML stream, with root tag named
         * "results", one "result" tag per row, and "result" child tag
         * names equal to the column name
         * @param query result set
         * @param list of column names to include in the result map
         * @throws SQLException if the query fails
         * @throws JDOMException if the XML stream creation fails
        public static final Document toJDOM(ResultSet rs, List wantedColumnNames)
            throws SQLException, JDOMException
            Element rows         = new Element("results");
            int numWantedColumns = wantedColumnNames.size();
            while (rs.next())
                Element row = new Element("result");
                for (int i = 0; i < numWantedColumns; ++i)
                    String columnName   = (String)wantedColumnNames.get(i);
                    Object value = rs.getObject(columnName);
                    row.addContent(new Element(columnName).setText(value.toString()));
                rows.addContent(row);
            return new Document(rows);
        }It uses JDOM from www.jdom.org. - MOD

  • How to: SELECT statement returns the result in XML format.

    That's it... I want to execute a query that returns all rowset in XML format. How can I do it?
    Using Oracle 8.0 and up.
    Tnx.

    FOR XML is a proprietary Microsoft Hack... It is not supported by Oracle in any release. Oracle 9.2.x includes the SQLXML operators, which are part of the SQL:2003 standard and are the agreed upon (Mircosoft, IBM, Oracle etc) way of generating XML from relational data....
    See http://download-west.oracle.com/docs/cd/B12037_01/appdev.101/b10790/xdb03usg.htm#sthref251

  • How a SELECT statement can return the results in XML format

    That's it... I want to execute a query that returns all rowset in XML format. How can I do it?
    I have Oracle 9i
    Thanks
    Jaime

    9i, or 9iR2 ?. If 9i I would recommend upgrading to 9iR2 and then using the SQL/XML operators.

  • How can I architect my data layer to yield query result pages to the application as SQL Server prepares them?

    I tried to make the question as explicit as possible.
    Refer to Sql Server Management Studio's Results view.  Depending upon the structure of the execution plan, the Results pane may begin displaying results while the query is still executing.  Can someone point me in a direction for architecting a
    data layer (I am tech and framework agnostic for this task. Any solution will suffice) that will begin receiving pages of the set before SQL Server has completed the entire query?
    The call from the data layer to SQL Server will obviously have to be asynchronous, but is there any additional ceremony that I need to be aware of when issuing OPTION (FAST x) to the query optimizer?

    Thanks for the reply. (I actually meant to put this in the SQL Data Access forum, not the T-SQL forum)
    "Generally the last step is ORDER BY in a
    query, so nothing can start before that executes."
    I would imagine you cannot ORDER BY and yield results as they are fetched because of the execution plan that would be generated.  For the purposes of this post, please assume that sorting will be done purely client side
    "Can you post your query?"
     For purposes of discussion, let's assume that the query is
    select *
    from information_schema.columns
    and also assume that you have "lots" of columns to display.
    This was an exploratory question to see what would be necessary to replicate the behavior of Management Studio's Query Result view in a custom application. 
    I would imagine that there's going to be a lot of analysis of the execution plans that get generated in order for the OPTION (FAST x) optimizer hint to do any good, but apart from general tuning concerns that would allow SQL SERVER to yield a page of data
    "fast", I was wondering if there was anything else required of the calling client to force it to yield return its first page.
    After thinking about this (and phrasing it the way I did in the last sentence) perhaps this is the incorrect forum for this question.  I imagine that my concerns are better addressed in forums dedicated to the technology of the calling client (which
    would be a .NET assembly)
    Be that as it may, if there is any ceremony that SQL Server imposes on clients in order to yield return, I would expect that my question would be in the scope of SQL Server discussions (even though I intended this to be in a different SQL Server forum)

  • How to store and retrieve a PDF form to SQL Server from LiveCycle?

    My intention is to save a complete PDF form into a database and then later on retrieve this form from DB.
    To do this, SQL Server has got two datatypes, image or Varbinary(max). I am able to store a PDF using "Execute SQL Statement"(I have written an Insert statement). Some value is being written into DB as well.
    But when I try to retrieve this record using "Query Single Row"(I store the result to a doc variable), the retrieved PDF is of an unknown type and cannot be opened by Adobe Reader.
    I am not sure if my approach is correct. Is it possible to store/retrieve a PDF form to/from a DB through LiveCycle?
    If yes, please give me some guidance.

    hi
    am not sure
    but u can use the same concept as storing image in db and retrieve..
    create a blob column
    parse that pdf and store into that column.
    again u retrieve the content and via file io make the same name with pdf extension..

  • Oracle/XML Question from MS SQL Server 2000 Developer

    With Microsoft SQL Server 2000 and Transact-SQL I can query a database and my results will be returned as an XML document. I need not do any further programmatic processing to transform my resultset into XML.
    I really know nothing about Oracle. That said, is this functionality available with Oracle/PL-SQL? And, if you could specify an URL where I might read up a bit on this, I'd really appreciate the point in the right direction.
    Thanks,
    --Isaac
    [email protected]

    Here is a link to a page that has some good information and examples and includes a lot of other links:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:4980337843276
    You can also search the Oracle on-line documentation and these forums for additional information. Here is a link to our FAQ home page, which includes a link to instructions on how to search the documentation and forums:
    Re: How to attach a java bean in forms6i
    There is also an XML DB forum. If you click on options near the upper right portion of your window, you can subscribe to that forum.

  • Trying to Connect to Reports 6i/NT Developer to SQL Server 7 using ODBC

    I am trying to connect Reports 6i Developer on NT through ODBC to SQL Server 7 (on same NT machine), and get an error message:
    ORA00022: invalid session id; access denied.
    When I try connecting using SQL*Plus, I get the following message:
    SQL*Plus: Release 8.0.6.0.0 - Production on Thu Mar 15 09:57:48 2001
    (c) Copyright 1999 Oracle Corporation. All rights reserved.
    ORA-00022: invalid session id; access denied
    ORA-00022: invalid session id; access denied
    ORA-00022: invalid session id; access denied
    Error accessing PRODUCT_USER_PROFILE
    Warning: Product user profile information not loaded!
    You may need to run PUPBLD.SQL as SYSTEM
    Server not available or version too low for this feature
    ORA-00022: invalid session id; access denied
    I can run SQL queries only after I have run a DESC <table name> command once. Otherwise, I get the following error:
    SQL> select * from authors;
    SQL*Plus internal error state 2090, context 246:0:0
    Unsafe to proceed
    Even with a DESC command is run, I can connect, but with an error as follows:
    SQL> desc authors
    ORA-00022: invalid session id; access denied
    Name Null? Type
    AU_ID NOT NULL VARCHAR2(11)
    AU_LNAME NOT NULL VARCHAR2(40)...
    ODBC Drivers used: I get the same results in Reports 6i and SQL *Plus with the Intersolv/Merant or Microsoft ODBC drivers for SQL Server. (Merant Version 3.7 for 32-bit SQL Server 6, 12/1/00)
    Please HELP.

    harry,
    i am assuming you are using 6.0.8.8 of reports6i, which is base-release. there have been problems withthe OCA in this version. by using the latest patch you should solve this problem. for further details, please contact oracle support services.
    regards,
    the oracle reports team

  • Error trying to install ICM 8.0 - "FAILED TO GET SQL SERVER VERSION."

    Hello guys, i tried to install ICM 8.0 but when i click on Setup.exe appears this error:
    "FAILED TO GET SQL SERVER VERSION. MAKE SURE SQL SERVER INSTALLED PROPERLLY
    NO INSTANCE NAME FOUND.NO SCHEMA UPGRADES ATTEMPTED"
    I try to check the SQL COnfiguration, about Named Pipes, but everything is allright. Someone knows what is it?
    Thank you very much.

    You should be able to see the ICMSetup.log file somewhere - check TEMP. It seems to me that this is the first thing it does - tries to connect to the SQL database and ask for the version. Clearly it cannot. I assume you installed SQL OK, probably have the service running under a domain user created especially for the task, or the domain admin, and you are also logged in as the domain admin, and that SQL is running.
    Check that log file for clues.
    Regards,
    Geoff

  • GregorianCalendar datetime format convert to  sql server date time format

    please help me
    my GregorianCalendar date time format is like this. *08/01/29 02:25:59* . I try to insert my database(sql server 2000 )
    data type is datetime ,in my database table display like this *2029-08-01 02:25:59.000* .can you help me to insert correct date in my database table like ( . *08/01/29 02:25:59*)

    use [PreparedStatement |http://java.sun.com/javase/6/docs/api/java/sql/PreparedStatement.html] and setTimestamp:
    [http://java.sun.com/docs/books/tutorial/jdbc/basics/prepared.html]

  • SSIS Import XML task running in SQL Server Agent fails

    I have created an SSIS package to import some XML files into my SQL2014 datawarehouse. If I run this package through the visual studio designer it works fine. The XML files are stored on a remote share accessed via UNC path. When I schedule the package to
    run using SQL server agent it fails with the following errors :-
    Executed as user: SPRINGFIELD\MSSQL. Microsoft (R) SQL Server Execute Package Utility  Version 12.0.2000.8 for 64-bit  Copyright (C) Microsoft Corporation. All rights reserved.    Started:  12:01:53  Error: 2014-11-18 12:01:59.78    
    Code: 0xC02090CF     Source: Import Screen XML XML Source [199]     Description: There was an error setting up the mapping. The device is not ready.  End Error  Error: 2014-11-18 12:01:59.78    
    Code: 0xC0047019     Source: Import Screen XML SSIS.Pipeline     Description: XML Source failed the prepare phase and returned error code 0xC02090CF.  End Error  DTExec: The package execution returned DTSER_FAILURE
    (1).  Started:  12:01:53  Finished: 12:03:32  Elapsed:  98.859 seconds.  The package execution failed.  The step failed.
    The user MSSQL has been granted full permissions to the remote share. If I remove these permissions then I don't get an error - but I also don't get any data imported. I have granted the MSSQL user xp_cmdexec permission. Both my SQL server database engine
    and agent are running as the MSSQL user.
    There must be some permission step I am missing - can anyone tell me what it may be ?

    FYI: The XSD path is hardcode... if you want it to be more flexible you can add an expression on that property:
    http://microsoft-ssis.blogspot.com/2014/09/xsd-location-hardcoded-in-xml-source.html
    Please mark the post as answered if it answers your question | My SSIS Blog:
    http://microsoft-ssis.blogspot.com |
    Twitter

  • Sending IDOC information in the XML format on the application server

    Hello All,
    We have a requirement like, while creating a billing document, an IDOC should be generated and the XML file should be created for that data in IDOC and that XML file would be sent to further via XI.
    For this purpose, we have created
    1. Logical Sender Receiver Systems  We are sending the data from DL3 system 100 client to DL3 800 client
    2. Assigned the clients to the logical system.
    3. Created the distribution model with the message type INVOIC.
    4. Created the partner profiles.
    5. Created an XML port in transaction WE21, in which the  application server file path is mentioned on which the xml file would be generated and the function module is provided which will only generate the file name is mentioned. In the outbound trigger tab the RFC destination is mentioned which is of type TCP/IP LOCAL_EXEC
    6. In transaction WE20, for the 100 logical system added the message type INVOIC as a outbound parameter and same for the 800 client. The receiver port is mentioned as XML port which we have created.
    Now, when we create the billing document via VF01 transaction, we give the transmission medium as ALE in the output. Hence the IDOC gets generated. The XML file also gets generated but the contents of the file are ONLY control records of the IDOC.
    And not the data record and the status records.
    The IDOC, if we see in WE02 displayes all the data in control , data and status records.
    We want the control, Data and Status records of the IDOC to be populated in the XML file.
    Please suggest if any extra configuration is required in this case. We are working on SAP 4.6.
    Thanks in advance for your answers.
    Regards,
    Anuja

    Hi Rob,
    Ya ,i will take care your suggestion from next time..
    Yes, we have downloaded the file using transaction CG3Y and opned it with IE as suggested by you. Howerver the contents are still seems to be control record.
    For your reference putting the contents of the file.
    <?xml version = "1.0"?><INVOIC01><IDOC BEGIN="1"><EDI_DC40 SEGMENT="1"><TABNAM><![CDATA[EDI_DC40]]></TABNAM><MANDT>100</MANDT><DOCNUM>0000000000227012</DOCNUM><DOCREL>46C</DOCREL><STATUS>30</STATUS><DIRECT>1</DIRECT><OUTMOD>2</OUTMOD><IDOCTYP>INVOIC01</IDO
    Please advice.
    Thanks.
    Regards,
    Anuja.

Maybe you are looking for

  • Problems viewing saved quicktime movies on other computers

    Currently using windows vista, When I save a movie file using quicktime I can not view it on other computers using other windows operating systems. Just get a blank screen hp Pavillion dv6000   Other OS   Windows Vista

  • Tiger Server: I can´t install on second HD

    Hello, I have a PM G5 with two internal HD, one with leopard client and other one empty. I can´t install Tiger Server on second HD because tiger server can´t startup on this hd. Can anybody help me? thanks.

  • Stopsap and db_offline

    Dear All, I'm running a database structure check right now. Database is online but SAP instance was not started. Question: If I issue a stopsap command, will it also trigger db_offline command for database? This is because when our server is shutdown

  • Repetitive error message on Calendar

    Hi, I'm having issues with my calendar. The error only applies to my Mac Calendar, I use the same synced calendar on my iphone and ipad and they work fine. Basically every time I open Calendar on the Mac I get an error box pop up as hopefully shown i

  • How to restore sync after reset?

    After a troubleshooting re-set on my windows pc my sync is no longer active. when i try to reactivate it on the tools drop-down i see two options: 1) "set up sync" which gives me the options of "create a new account" or "i have an account") or 2) too