SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SSIS Export to Flat File Question


SSIS Export to Flat File Question

Author
Message
Keejli69
Keejli69
SSC Veteran
SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)

Group: General Forum Members
Points: 237 Visits: 779
Hello All, I am a noobie. I am using SSIS 2008 R2 to export data from sql server 2008 R2 to a flat file. My question is how can i add a pipe delimiter to the end of the header column? I tried to add the pipe delimiter to the alias but it doesn't like it in SSIS. Right now i am able to get the output like this:

FirstName| LastName| Email
Jon| Doe| jd@email.com|
Mike| Jones| mj@email.com|

I need the output to be like this:

FirstName| LastName| Email |
Jon| Doe| jd@email.com|
Mike| Jones| mj@email.com|

Any help would be greatly appreciated. Thanks!!:-)
sdevanny
sdevanny
SSC-Enthusiastic
SSC-Enthusiastic (121 reputation)SSC-Enthusiastic (121 reputation)SSC-Enthusiastic (121 reputation)SSC-Enthusiastic (121 reputation)SSC-Enthusiastic (121 reputation)SSC-Enthusiastic (121 reputation)SSC-Enthusiastic (121 reputation)SSC-Enthusiastic (121 reputation)

Group: General Forum Members
Points: 121 Visits: 343
Redacted as this will not solve OP's problem.
Keejli69
Keejli69
SSC Veteran
SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)

Group: General Forum Members
Points: 237 Visits: 779
sdevanny (7/17/2013)
How did you add the | to the individual records? If that is easily removable you might try adding a Derived Column Transform and add a new column named (literally) | and make the expression "|".

This will add a column named | with a value of "|" to your data flow - just make sure it is the last column and you should be ok.

I am curious though, why do you need a column delimiter at the end of your record when there are no more columns in the record?

Thanks - hope this helped!


I added the pipe in the sql script like this below:

ADDRESS_MASTER.ADDR_LINE_1 + '|' AS 'email'



The vendor that is requesting this file would like a pipe delimiter at the end to close out that row of data.

Thanks!
Keejli69
Keejli69
SSC Veteran
SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)

Group: General Forum Members
Points: 237 Visits: 779
Not sure if i am doing this correct but i get an error as i followed your advice. I attached a screenshot.
Attachments
Doc2.docx (6 views, 56.00 KB)
Keejli69
Keejli69
SSC Veteran
SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)

Group: General Forum Members
Points: 237 Visits: 779
elee1969 (7/17/2013)
Not sure if i am doing this correct but i get an error as i followed your advice. I attached a screenshot.



i figured it out. I forgot to add the quotation marks.
sdevanny
sdevanny
SSC-Enthusiastic
SSC-Enthusiastic (121 reputation)SSC-Enthusiastic (121 reputation)SSC-Enthusiastic (121 reputation)SSC-Enthusiastic (121 reputation)SSC-Enthusiastic (121 reputation)SSC-Enthusiastic (121 reputation)SSC-Enthusiastic (121 reputation)SSC-Enthusiastic (121 reputation)

Group: General Forum Members
Points: 121 Visits: 343
If you used my suggestion with a dervied column, you might want to double check and make sure that you have a correct count of delimiters and columns now. I believe that my suggestion will actually add one extra delimiter - sorry I missed that when originally replied.
Keejli69
Keejli69
SSC Veteran
SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)

Group: General Forum Members
Points: 237 Visits: 779
sdevanny (7/17/2013)
If you used my suggestion with a dervied column, you might want to double check and make sure that you have a correct count of delimiters and columns now. I believe that my suggestion will actually add one extra delimiter - sorry I missed that when originally replied.


i checked and you are correct. I get this now:

partnerkey|first_name|middle_name|last_name|email||
12345|David|jones|jones |jones@email.com||

How do i fix this?

Thanks!
Steven Willis
Steven Willis
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1929 Visits: 1721
elee1969 (7/17/2013)
sdevanny (7/17/2013)
If you used my suggestion with a dervied column, you might want to double check and make sure that you have a correct count of delimiters and columns now. I believe that my suggestion will actually add one extra delimiter - sorry I missed that when originally replied.


i checked and you are correct. I get this now:

partnerkey|first_name|middle_name|last_name|email||
12345|David|jones|jones |jones@email.com||

How do i fix this?

Thanks!

Any of these methods will do the job...



DECLARE @str AS VARCHAR(500)

SET @str = 'partnerkey|first_name|middle_name|last_name|email||'
SET @str = REPLACE(@str,'||','|')
SELECT @str

SET @str = 'partnerkey|first_name|middle_name|last_name|email||'
SET @str = LEFT(@str,LEN(@str)-1)
SELECT @str

SET @str = 'partnerkey|first_name|middle_name|last_name|email||'
SET @str = REVERSE(STUFF(REVERSE(@str),1,1,''))
SELECT @str




 
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search