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


SSIS Exporting to CSV and Opening File in CSV


SSIS Exporting to CSV and Opening File in CSV

Author
Message
koti.raavi
koti.raavi
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2095 Visits: 421
Hi ,
In SQL DB- We do have a column ID, which is more than 12 digits length (EX: 854597754782).
Created process to export to csv file ( Delimited - ") and it iscausing issue while opening in excel file - issue is number format (ID contains + Symbol 8545+54782).
To handle this converted ID to varchar(100) and added CHAR(9) - it is displaying correctly in excel but end of ID some space is exists .
Due to limitations we can't directly to csv, is there any way to handle this situation?

Hope it is clear, if any questions please let me know

Thanks,
Koti.
Phil Parkin
Phil Parkin
SSC Guru
SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)

Group: General Forum Members
Points: 221177 Visits: 25131
koti.raavi - Thursday, December 6, 2018 9:14 AM
Hi ,
In SQL DB- We do have a column ID, which is more than 12 digits length (EX: 854597754782).
Created process to export to csv file ( Delimited - ") and it iscausing issue while opening in excel file - issue is number format (ID contains + Symbol 8545+54782).
To handle this converted ID to varchar(100) and added CHAR(9) - it is displaying correctly in excel but end of ID some space is exists .
Due to limitations we can't directly to csv, is there any way to handle this situation?

Hope it is clear, if any questions please let me know

Thanks,
Koti.

Can you take Excel out of the equation (because it tends to mess with your data) and open the file in Notepad++ instead?

Then do a View/Show Symbol/Show All Characters to see whether anything has been added.

Also, why would you need to add a CHAR(9) to anything? Please provide more detail about that.



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Jeffrey Williams 3188
Jeffrey Williams 3188
SSC Guru
SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)

Group: General Forum Members
Points: 79477 Visits: 11488
koti.raavi - Thursday, December 6, 2018 9:14 AM
Due to limitations we can't directly to csv, is there any way to handle this situation?

From this - it appears that you want to get this output to a CSV file. If so - what are the so-called limitations you are running into with going directly to CSV from SSIS? Probably a lot less time and effort to address those limitations than to worry about issues with exporting from SSIS to Excel.

[quote]
Phil Parkin - Thursday, December 6, 2018 10:31 AM
Also, why would you need to add a CHAR(9) to anything? Please provide more detail about that.

Phil - if you add a CHAR(9) to the beginning of a field in Excel it forces that field to be interpreted as a text field and not a numeric field, but that is only when the data in imported into Excel from a comma/tab delimited file. If SSIS is exporting directly to Excel - then you should be able to define the column types in the Excel 'table' as specific data types.


Jeffrey Williams
Problems are opportunities brilliantly disguised as insurmountable obstacles.

How to post questions to get better answers faster
Managing Transaction Logs

Phil Parkin
Phil Parkin
SSC Guru
SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)

Group: General Forum Members
Points: 221177 Visits: 25131
Phil - if you add a CHAR(9) to the beginning of a field in Excel it forces that field to be interpreted as a text field and not a numeric field, but that is only when the data in imported into Excel from a comma/tab delimited file. If SSIS is exporting directly to Excel - then you should be able to define the column types in the Excel 'table' as specific data types.


Ah, makes sense, thank you.

The OP suggested that the CHAR(9) was 'added' – made it sound like it was appended to the column, rather than being spliced in at the beginning.


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
koti.raavi
koti.raavi
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2095 Visits: 421
Correct Jeff, I don't want to export to excel due to CSV is much faster than Excel exporting. It's not one file to open and format data in excel. We are exporting around 400 files to CSV everyday and user will open in excel. It is exporting correctly when we add CHAR(9) to column but the issue is with Space .

Here is the space example:
current output : "854597754782 "
desired output : "854597754782"
Let me know any questions.

Thanks for you're help

Thanks,
Koti.

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