We help IT Professionals succeed at work.

SSIS Package Flat File Output Question

I am using SSIS to output results from a query to a flat file.  I need the results to output as:   The Help Guru|7.28||||||||.

Instead, the output is :   The Self Help Guru|7.28|

How do I get my data to output as The Help Guru|7.28||||||||?

It looks like my blank fields are not being displayed with empty pipes.
Comment
Watch Question

lcohanDatabase Analyst
CERTIFIED EXPERT

Commented:
You need to set the field dilimiter in your SSIS task to use the pipe character
lcohanDatabase Analyst
CERTIFIED EXPERT

Commented:
Are all those fields NULLs? You may need to change that to empty string '' instead

Author

Commented:
lcohen,

I have set my delimiter to pipes in my SSIS package.

I also set my empty fields to empty strings ('') and those fields were still excluded from my flat file output.
lcohanDatabase Analyst
CERTIFIED EXPERT

Commented:
If xp_cmdshell is enabled in your SQL then you could try explicit SQL like in example below where you can replace column list and tablename in the select statement:

exec master..xp_cmdshell N'sqlcmd -E -Q"select name,''|'',database_id,''|'',source_database_id,''|'',owner_sid,''|'',create_date from master.sys.databases" -h-1 -s"," -W -o"c:\output.txt"'--, no_output

Author

Commented:
xp_cmdshell is not  enabled
Database Analyst
CERTIFIED EXPERT
Commented:
If it's not against your company policy ( I can say that we are PCI compliant and they have nothing against it) you could enable it by running the code below but check with your IT or whomever is taking care of your internal policies before that:

EXEC sp_configure 'show advanced options', 1
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1
GO
-- To update the currently configured value for this feature.
RECONFIGURE
GO

Author

Commented:
lcohan,

Thanks for the above - I will check and let you know!

Author

Commented:
Lcohan,

Your suggestion won't work - compliance issue.  I also noticed an additional issue.  All of my fields aren't displaying when exported to the flat file.  Of the 20 fields displayed, only 12 are displaying.  It's almost like once the output gets to a NULL value, it ignores everything after that.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.