February 2, 2010 at 3:39 pm
On exporting the query results in dataflow task from the SQL server 2005 database, the null values are exported as blanks in to the flat file. But i want to retain the same null values.
February 2, 2010 at 4:39 pm
>>But i want to retain the same null values.
You question seems to indicate the following article may be helpful.
http://en.wikipedia.org/wiki/Null_(SQL)
I am going to guess and say you want the phrase 'NULL' to appear in your export.
Use COALESCE
http://msdn.microsoft.com/en-us/library/ms190349.aspx
SELECT COALESCE(YourField,'NULL')...
If you field is NULL you then will return the string 'NULL'
February 4, 2010 at 6:45 am
Please show an actual example of the data in your flat file which shows how 'blank' and 'null' differ.
February 4, 2010 at 8:06 am
Here is the sample data
Sample Value where null is replaced
DATABASE VALUES- Affinity,NULL,CT
EXPORTED VALUES IN FLAT FILE(blank) - Affinity,,CT
February 4, 2010 at 8:12 am
,, in a text file is the equivalent of NULL in a database table.
February 4, 2010 at 9:14 am
Thanks emily but still 'NULL' and NULL makes a difference when you import in the table.
February 4, 2010 at 9:26 am
You use the word 'retain' in your original post. If a value is null in a database column and you export it to a text file, the way of retaining that value is to export it as ,,
anything else is changing it, not retaining it.
February 4, 2010 at 10:01 am
Thank you phil but ,, when imported again into the database is inserted as Space and not null so that makes a difference. As we are feeding into other applications, we cannot change the importing code. Try this by exporting and reimporting.
February 4, 2010 at 12:42 pm
Something else is happening here.
If I import the record
Affinity,,CT
into a database, I can guarantee that field number 2 would not somehow become a space in my database table. Do you really mean a space (one character), or just an empty string?
February 4, 2010 at 12:47 pm
It is empty string
February 4, 2010 at 1:04 pm
I just tried it and it worked as I suggested.
Against the properties for your flat file source, have you got 'retain nulls' set to true?
Viewing 11 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply