blogs.conchango.com

welcome to the conchango blogging site
Welcome to blogs.conchango.com Sign in | Join | Help
in Search

SSIS Junkie

Conchango are busy and need top level Technical Architects for Microsoft & Open Source platforms in and around London. Interested? Email me or send me a message

SSIS: Appending to a raw file

Just lately I've been breaking the cardinal rule of blogging: "Thou shalt always blog". Well the reason is simply that I've been heads-down on my current project and:

a) Haven't had anything to blog about and

b) Haven't got time to anyway!

 

Well b) is still true but a) isn't so I'm back blogging! This is all to do with using the Raw File Destination adapter in a data-flow. Our requirement was to be able to loop through a series of data sources with identical metadata, appending the data to a raw file on each iteration. This would then enable us to process all of the data from the multiple sources all at the same time. UNION ALL was not an option here because we don't know how many sources exist.

The behaviour of a raw file at runtime depends on the WriteOption property. BOL states:

Create once

Creates a new file. If the data flow that uses the Raw File destination is in a loop, the file is created once and data is appended to the file when the loop repeats. The data appended to the file must match the file format.

Well that sounded like it did exactly what we wanted! Well unfortunately not - it turns out that this is a documentation bug (which I notified Microsoft of via the "Send Feedback" link in BOL) and WriteOption="Create Once" doesn't do what we want at all.

Thanks to expert SSIS tester Ranjeeta Nanda however I was able to get this working. If you want to create a raw file on the first iteration of a loop and then append to it thereafter here are the steps you need to follow:

1) To use the Append option you first need to create the file at design time so that the package knows about the metadata of the raw file. To do this set WriteOption="Create Always" and run your package. Barring any mishaps your raw file should be created!

2) Edit your Raw File DestinationAdapter. Set WriteOption="Append" & ValidateExternalMetadata="False". This second setting is important because it means you can delete the raw file from file storage and the package will not complain about it.

3) Any data flows that source data from this raw file must have DelayValidation=TRUE so that they don't fail validation on account of the raw file not existing when the package starts up

You should now be able to run a data-flow inside a loop, appending to a raw file as on each iteration.

 

Thanks very very much Ranjeeta - this was becoming, nay had already become, a huge problem for us!

-Jamie

Published 01 December 2005 12:07 by jamie.thomson

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

SimonS SQL Server Stuff said:

In my presentation last night I went through a process by which you can create Raw files so that you...
June 23, 2006 10:31
 

Frans van Bree said:

Jamie,

A guy named Gerald Aichholzer had some troubles which your 1-2-3 approach during step 2. It involves errors like:

"component "Raw File Destination" (1443)" failed validation and returned
validation status "VS_NEEDSNEWMETADATA".

and

The external metadata collection is out of synchronization with
the data source columns.
The column "..." needs to be added to the external metadata
collection
...
Do you want the component to fix these errors automatically?

You can find the tread here:
http://www.microsoft.com/technet/community/newsgroups/dgbrowser/en-us/default.mspx?dg=microsoft.public.sqlserver.dts&tid=b17392a3-922a-4628-b9c5-260e7e8ea270&cat=en-us-technet-sqlserv&lang=en&cr=US&sloc=en-us&m=1&p=1

Did we miss anything here? We both fixed it independantly in almost the same fashion.

His proposal at the end of the tread of splitting step 2 into sub-steps a, b, and c seems like a good addition.
July 13, 2006 15:23
 

jamie.thomson said:

Frans,
I suppose this can be a bit of a fiddly operation but I've read through all that thread and it looks like you've got it sorted.

I have reproduced your problem as well. it does seem as though setting WriteOption="Append" & ValidateExternalMetadata="False" in 2 seperate steps solves the problem.

Thanks for your comments. let's hope people make it as far as reading this comments section :)

-Jamie
July 13, 2006 15:46
 

Palanivel said:

Mr Thomson,

I want to write the recordcount in the header of the flat file which i am generating by using datareader source and flat file destination . have any idea how to do that?

-Palanivel.

May 15, 2007 08:31
 

Cade Roux said:

This is still not working for me.

I've tried it in 2 steps and in different orders (after the raw file is created using create always)

[DTS.Pipeline] Error: "component "Raw File Destination" (378)" failed validation and returned validation status "VS_NEEDSNEWMETADATA".

April 22, 2008 00:11

Leave a Comment

(required) 
(optional)
(required) 
Submit

This Blog

Syndication

News

Powered by Community Server (Personal Edition), by Telligent Systems