Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Export DB table with columns that have NULL values

$
0
0

Assume I have a table ABC with 3 columns (nvarchar(10), nvarchar(3), nvarchar(1)) which are all nullable. Sample data are as follows

ABCXXXXXX1, 123, F
ABCXXXXXX2, NULL, S
ABCXXXXXX3, 123, NULL
ABCXXXXXX4, NULL, NULL

We would like to export the table into a plaintext file. All columns are packed together without delimiter

ABCXXXXXX1123F
ABCXXXXXX2   S
ABCXXXXXX3123
ABCXXXXXX4

We tried BCP utility to export. The result looks nice until we open the txt file with Notepad++.

For any columns with NULL value, it is found that the tools append "NUL" character which cannot be seen in Notepad but in Notepad++. For example, if the second column is NULL, it will be shown as "NUL NUL NUL". This is not what we want. If there are NULL values, we would rather use space to fill the gap.

As it looks like there is no solution for BCP (correct me if we are wrong), we would like to investigate whether it is possible to do that with SSIS. The package should be simple and can be applied to any tables.

Thank you very much for your help.


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>