Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7191473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:44:10+00:00 2026-05-28T19:44:10+00:00

I’m trying to use SSIS to extract XML representation of a query result set

  • 0

I’m trying to use SSIS to extract XML representation of a query result set to a text file. My query is currently successfully extracting the exact XML output I need when I run it in SSMS. I’ve tried every trick I can find to use this result set in a SSIS package to create a file.

Using a dataflow to port a OLE Source to a Flat file doesn’t work because the output of a XML query is treated as TEXT and SSIS can’t push TEXT, NTEXT or IMAGE to a file destination.

I’ve tried to then Execute SQL Task to fill a user variable and then use a Script Task (written using C#) to write the contents of this user variable to a file output, but the user variable is always empty. I don’t know, but I suspect this is, again, because the XML is treated as TEXT or IMAGE and the user variable doesn’t handle this.

The query is in this form:
SELECT *
FROM dataTable
WHERE dataTable.FIELD = ‘Value’
FOR XML AUTO, ROOT(‘RootVal’)

The resulting dataset is well formed XML, but I can’t figure out how to get it from result set to file.

It’s a relatively easy task for me to write a console app to do this in C# 4.0, but restrictions require me to at least prove it CAN’T be done with SSIS before I write the console app and a scheduler.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:44:11+00:00Added an answer on May 28, 2026 at 7:44 pm

    Sorry to spoil, but there’s an SSIS option for you: Export Column Transformation.

    I defined an OLE DB query with

    SELECT
        *
    FROM
    (
        SELECT * FROM dbo.spt_values FOR XML AUTO, ROOT('RootVal')
    ) D (xml_node)
    CROSS APPLY
    (
        SELECT 'C:\ssisdata\so_xmlExtract.xml'
    ) F (fileName)
    

    This results in 1 row and 2 columns in the dataflow. I then attached the Export Column Transformation and wired it up with xml_node as Extract Column and fileName as the File Path Column

    Mostly truncated results follow

    <RootVal>
        <dbo.spt_values name="rpc" number="1" type="A  " status="0"/>
        <dbo.spt_values name="dist" number="8" type="A  " status="0"/>
        <dbo.spt_values name="deferred" number="8192" type="V  " low="0" high="1" status="0"/>
    </RootVal>
    

    A more detailed answer, with pictures, is available on this Q&A Export Varbinary(max) column with ssis

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I am trying to understand how to use SyndicationItem to display feed which is
I am trying to render a haml file in a javascript response like so:
In my XML file chapters tag has more chapter tag.i need to display chapters
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a reasonable size flat file database of text documents mostly saved in
I'm parsing an XML file, the creators of it stuck in a bunch social
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.