Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have created a package that Runs a Sql Query and then puts the results into a flat tab delimited txt file.

When I opened the flat file in excel everything was in the right columns but in columns where i had a combination of alpha characters and numerical characters I was getting extra trailing blank spaces in certain records (as shown below). What I did was, added a derived Column step where i would do RTRIM(memberid) which successfully removed the trailing spaces but now the column was still aligned to the left while all the other records were aligned to the right. Has anyone ever come across this scenario and is there anything i can do so that the columns are all aligned to the RIGHT?

    123123
    123333
MC1234
     32212
     12546
     35265
C423621
share|improve this question
add comment

closed as off topic by Mark Storey-Smith, Max Vernon, Jon Seigel, Derek Downey, RolandoMySQLDBA Apr 5 '13 at 15:15

Questions on Database Administrators Stack Exchange are expected to relate to database administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

up vote 3 down vote accepted

The columns that are aligned to the right are deemed as numeric fields by Microsoft Excel, anything with a letter in it is deemed an alphanumeric field.

I do not believe there is an export method in SQL Management that would have Excel change the alignment of the cells, any change in formatting would need to be done in Excel post-export.

Alternatively, if you just want the alignment to be consistent, you could import the text with the Text Import Wizard and set all the columns to have 'Text' formatting.

share|improve this answer
    
Thank you. I guess the most important part was getting rid of the Trailing Blank spaces which I was able to do. I Just have to let the end user know that the alignment of the data does not change the data. Thank you for explaining this to me. –  JuanVelez Apr 1 '13 at 20:13
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.