SSIS --> XML output

  • Building off of the previous example:

    DECLARE @ContactTable TABLE(

    Date char(11) NULL,

    Job varchar(100) NULL,

    Telephone varchar(100) NULL,

    Company nvarchar(255) NULL

    )

    INSERT INTO @ContactTable

    SELECT '2009-01-01', 'Site Manager', '0208 7845111', 'SoftCom' UNION ALL

    SELECT '2009-01-01', 'Stock Room', '0208 7845112', 'SoftCom' UNION ALL

    SELECT '2009-01-01', 'Area Manager', '0208 7845113', 'FilmView' UNION ALL

    SELECT '2009-01-01', 'Stock ***', '0208 7845114', 'OfCom' UNION ALL

    SELECT '2009-01-01', 'Control', '0208 7845115', 'TecNet'

    DECLARE @XML varchar(max)

    SET @XML = (

    SELECT Company,

    Job,

    Telephone,

    Date

    FROM @ContactTable Contact

    FOR XML AUTO, ELEMENTS, ROOT('Contacts'))

    SET @XML = '' + @XML

    SELECT @XML

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

Viewing post 16 (of 15 total)

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