SP with Select * from table for xml auto

  • I have created a stored procedure that will take a xml stream as parameter and return the processed data after insert with openxml.

    The sp return a result generated from the following:

    for example ->

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

    will generate output

    XML_F52E2B61-18A1-11d1-B105-00805F49916B---------------------------------------------------------------------------------------

    <employees><EmployeeID>1</EmployeeID><LastName>Davolio</LastName>......

    but I only want to return the actual xml stream WITHOUT this GUID and the lines.

    Can someone maybe give me a hint.

    I guess it has something to with turning off the column heading but the problem is that I will be doing this in a stored procedure at run-time.

    I appreciate any help

  • If you are doing this in QA then

    1) Tools->Options

    2) "Results" Tab

    3) Uncheck "Print column headers (*)"

    4) Press "OK"

    Also, you may want to do

    SET NOCOUNT ON

    in the batch like so.

    SET NOCOUNT ON

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

    otherwise you get a

    (n row(s) affected)

    message at the bottom of the results.

  • Why does the column header matter? You only see it if you save it directly to a file.

    If you are going to have a 'front-end' to run this t-sql then you can get rid of the header there.

    If you are looking to save it to file from QA then look at the settings.

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

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