Results 1 to 2 of 2

Thread: populating sql table with xml from sql table

  1. #1
    Join Date
    Nov 2002
    Posts
    261

    populating sql table with xml from sql table

    I need to populate a queue table with an orderid, and the rest of the order in an xml auto element format going into a text field.
    The data is coming from another sql server table. I was going to do this is an sp and started with below

    declare @request text
    set @request = (select orderid,* from neworder
    For XML auto,ELEMENTS)
    However it errors on the statement. I can run the select by itself fine, but need to store the output.
    Any ideas

  2. #2
    Join Date
    Feb 2003
    Posts
    1,048
    From BOL:

    Guidelines for Using the FOR XML Clause
    The FOR XML clause is valid only in the SELECT statement and is subject to these limitations:

    FOR XML is not valid in subselections, whether it is in UPDATE, INSERT, or DELETE statements, a nested SELECT statement, or other statements (SELECT INTO, assignment). For example, subselects as shown in these examples are not supported:

    Example B

    DECLARE @doc nchar(3000)
    SET @doc = (SELECT * FROM Customers WHERE CustomerID = 'ALFKI' FOR XML RAW)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •