Does SQL Server support XML Functions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Amardeep Verma

    Does SQL Server support XML Functions

    Hi,
    Do any versions of SQL Server support the following functions, as
    they appear in the Oracle Database:-

    1) XMLElement
    2) XMLAttributes
    3) XMLForest

    Thanks in Advance for your reply
    Bye
    Amardeep Verma
  • Erland Sommarskog

    #2
    Re: Does SQL Server support XML Functions

    Amardeep Verma (addverma@netsc ape.net) writes:[color=blue]
    > Do any versions of SQL Server support the following functions, as
    > they appear in the Oracle Database:-
    >
    > 1) XMLElement
    > 2) XMLAttributes
    > 3) XMLForest
    >
    > Thanks in Advance for your reply[/color]

    Since I don't know Oracle, I don't know what these functions do. It is
    not likely that SQL Server supports these functions directly, but it
    may support the same functionality. You would need to explain what these
    functions do to get answer.


    --
    Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

    Books Online for SQL Server SP3 at
    Get the flexibility you need to use integrated solutions, apps, and innovations in technology with your data, wherever it lives—in the cloud, on-premises, or at the edge.

    Comment

    • Amardeep Verma

      #3
      Re: Does SQL Server support XML Functions

      Hi,
      Thanks Erland for your Response. These Functions take simple
      SELECT statement and return the result in a XML format. With each
      Column name as a tag and the value in that column as the data.
      For Example the Employee Table of NorthWind Database has 3
      columns:-
      1) EmpNo
      2) EmpLastName
      3) EmpFirstName
      Then using the below mentioned functions we can get the output
      <EMP>
      <EMPNo>1</EMPNo>
      <EMPFirstName>A BC</EMPFirstName>
      <EMPLastName>XY Z</EMPLastName>
      </EMP>

      Hope this helps
      Amardeep Verma

      Erland Sommarskog <esquel@sommars kog.se> wrote in message news:<Xns9536EC 50E4C4FYazorman @127.0.0.1>...[color=blue]
      > Since I don't know Oracle, I don't know what these functions do. It is
      > not likely that SQL Server supports these functions directly, but it
      > may support the same functionality. You would need to explain what these
      > functions do to get answer.[/color]

      Comment

      • Erland Sommarskog

        #4
        Re: Does SQL Server support XML Functions

        Amardeep Verma (addverma@netsc ape.net) writes:[color=blue]
        > Thanks Erland for your Response. These Functions take simple
        > SELECT statement and return the result in a XML format. With each
        > Column name as a tag and the value in that column as the data.
        > For Example the Employee Table of NorthWind Database has 3
        > columns:-
        > 1) EmpNo
        > 2) EmpLastName
        > 3) EmpFirstName
        > Then using the below mentioned functions we can get the output
        ><EMP>
        > <EMPNo>1</EMPNo>
        > <EMPFirstName>A BC</EMPFirstName>
        > <EMPLastName>XY Z</EMPLastName>
        ></EMP>[/color]

        It looks like you should study the FOR XML clause in the SELECT statement.
        It gives you several possibilities. Rather than typing examples here,
        I refer you to Books Online myself, since I am no XML wizard myself.


        --
        Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

        Books Online for SQL Server SP3 at
        Get the flexibility you need to use integrated solutions, apps, and innovations in technology with your data, wherever it lives—in the cloud, on-premises, or at the edge.

        Comment

        • DMAC

          #5
          Re: Does SQL Server support XML Functions

          SQL sever has a few ways to generate xml. An example below that
          conforms to your spec(ie columns as elements) can be viewed in QA

          select * from employees
          where employeeid=1 for xml auto, elements

          NOTE: it is best run when the query is set to 'Results in text' and
          also
          'DBCC TRACEON(257)' has been run first

          Comment

          Working...