SSIS- retaining null values as null in the csv output file using script task -


i using execute sql task read sql queries , script task write query results csv files using method mentioned in following post on site-

ssis: script task write recordset file (ssis: script task write recordset file). in addition this, require 'null' populated in csv files wherever query result null. how achieve using script task???? additional code have write??

there few ways answer in persist() within foreeach data row loop:

       foreach (system.data.datarow row in table.rows)         {             // todo: string based fields, capture max length             ienumerable<string> fields = (row.itemarray).select(field => field.tostring());              file.writeline(string.join(delimiter, fields));         } 

you have test db null in lambda expression. should work though have not tested:

ienumerable<string> fields = (row.itemarray).select(field => ((field  == dbnull.value) "null" : field.tostring())); 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -