Return the resultSet in XMl format

  • Hi Guys,

    I have Database in SQL SERVER 2008.In this datbase I have Message table,which has the following Columns:

    MessageId

    MessageDateTime

    MessageText

    FromId

    ToId

    Which FromId & ToId are referenced to User table.Now I want to create a XML format like:

    <File Temp>

    <Message>

    <MessageId></MessageId>

    <Messagetext> </Messagetext>

    <Sender>

    <FirstName>

    </FirstName>

    <LastName>

    </LastName>

    </Sender>

    <Recipient DeliveryType="">

    <FirstName>

    </FirstName>

    <LastName>

    </LastName>

    </Recipient>

    </Message>

    I was wondering how can I create that TSQL statment

  • Using FOR XML you can get it done.

    Providing the DDL scripts for the tables, and INSERT statements to put some test data into those tables and some sample result will help giving quickly solutions.

    For more details on posting your query please take a look at this link

    http://qa.sqlservercentral.com/articles/Best+Practices/61537/

    Nag.

    Nag
    ------------------------------------------------
    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply