Answered by:
Why are columns not aligned when createing txt file.

Question
-
I am sending resluts from query to a flat file, then using flat file for the body of email I send. I am having hard time aligning my 4 columns columns. I have tried various combination of delimited and fixed width columns. I have tried .txt and .htm extensions on flat file. All feilds are cast as nvarchars in SQL query, including some dates.
However my flat file looks is how the body looks, so I am convinced if I can get the colunms aligned in the flat file, the columns will be aligned in the body of my email.
how ever I configure my flat file connection I can't get the columns to alighn.
Will the approach I am taking even work, as far as aligning columns? Everything works great except columns are not aligned.
Any help appreciated
Please help,
Thanks,
Mike
Wednesday, January 29, 2014 10:45 PM
Answers
-
The email body looks just like the txt file. They are not aligned in the text file
Hi Mike,
Do you mean the columns are not aligned in the flat file destination? First, we need to make sure the data are well formatted in the flat file. Based on my test, if we set the Flat File Format to either “Fixed width with row delimiters” or “Ragged right”, the text in the CSV file is well formatted. When using the “Fixed width with row delimiters” format, we don’t need to change the default value of header row delimiter ({CR}{LF}) and don’t need to map a input column to the destination column “Row delimiter column”.
However, even though the text in the flat file is well formatted, the text format displayed in the email body may be different. It is related to the Client or Web application you use to view the email. Based on my test, the following screenshot illustrates how the same well formatted text are rendered in Outlook, Gmail (Web), and Live (Web):
Regards,
Mike YinIf you have any feedback on our support, please click here
Mike Yin
TechNet Community Support- Marked as answer by Mike Yin Sunday, February 9, 2014 3:23 PM
Monday, February 3, 2014 5:08 AM
All replies
-
Hi Mike,
To make your columns get aligned you must have target flat file as Fixed width Format instead of any Column delimiter.
When you use column delimiter then it will align as the column data length it is receiving from the source.
Check this link
http://sqlserverandbi.blogspot.com/2012/10/create-fixed-width-text-file-using-flat.html
Regards
Naveen
- Edited by Naveen Kumar K.R Thursday, January 30, 2014 7:20 AM
- Proposed as answer by Satheesh Variath Thursday, January 30, 2014 9:18 AM
Thursday, January 30, 2014 7:19 AM -
Choose your delimiter as {CR}{LF}
Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.
Thursday, January 30, 2014 8:25 AM -
Thursday, January 30, 2014 8:34 AM
-
I tried using fixed with, but then it messed up my row delimiter. It would come across like one long string and wrap acccording to how big the window is. I tried different things but could get the cariage return after each row
Since my dataset is small (30 rows, 4 columns), I was thinking about saving the result set to a variable and then linking the body of my email to the variable.
Thursday, January 30, 2014 7:48 PM -
The email body looks just like the txt file. They are not aligned in the text fileThursday, January 30, 2014 10:32 PM
-
If my columns are fixed width, what should my row delimiter be?Thursday, January 30, 2014 10:33 PM
-
The email body looks just like the txt file. They are not aligned in the text file
Hi Mike,
Do you mean the columns are not aligned in the flat file destination? First, we need to make sure the data are well formatted in the flat file. Based on my test, if we set the Flat File Format to either “Fixed width with row delimiters” or “Ragged right”, the text in the CSV file is well formatted. When using the “Fixed width with row delimiters” format, we don’t need to change the default value of header row delimiter ({CR}{LF}) and don’t need to map a input column to the destination column “Row delimiter column”.
However, even though the text in the flat file is well formatted, the text format displayed in the email body may be different. It is related to the Client or Web application you use to view the email. Based on my test, the following screenshot illustrates how the same well formatted text are rendered in Outlook, Gmail (Web), and Live (Web):
Regards,
Mike YinIf you have any feedback on our support, please click here
Mike Yin
TechNet Community Support- Marked as answer by Mike Yin Sunday, February 9, 2014 3:23 PM
Monday, February 3, 2014 5:08 AM