Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hello ,im new to SSIS and im trying to fetch data from sql server and load into excel but problem is that when data will be loaded into excel its become a string automaticaly ,i want my data in my correct datatype.

What I have tried:

fetched data and load into excel but decimal field is become string into excel ,
Posted
Updated 3-Jul-17 12:51pm

Have a look at this blog (disclaimer - nothing to do with me): Why SSIS always gets Excel data types wrong, and how to fix it! | CONCENTRA[^]

There are further alternatives discussed here - Export to Excel with correct data type[^]
 
Share this answer
 
v2
Comments
Member 12270370 4-May-17 6:47am    
i had done all step shown in link but problem is still same .
CHill60 4-May-17 6:51am    
I've added an alternative to my solution
This is an example how to store data from your SQL Server database to local Excel file keeping the same data type as in the database table.

1. Create your Excel destination file with a heading row (name your columns).

2. Insert "a dummy row" (the first one below the heading) and fill it with data following this logic: "abc" for string, 0 for integer, 0.00 for decimal etc.

3. In your SSIS solution in Data Flow create OLE DB Source (define a connection string to the database) and Excel destination (define a path to the destination file).

4. Add Data Conversion between database source and Excel destination. In data conversion editor set the columns that contain text to 'Unicode string [DT_WSTR]' and set the columns that contain decimal numbers to 'decimal[DT_DECIMAL]'. Now map the columns between Data conversion step and Excel destination.

Finally, you'll have to delete dummy row in your Excel file. The point is - Excel will keep the same data type as you mention in the dummy row.
 
Share this answer
 
v2
Comments
CHill60 4-Jul-17 17:14pm    
You may need up to 8 dummy rows depending on the data you are trying to import
Lazar Jovovic 5-Jul-17 8:19am    
Up to 8 dummy rows? Not at all. As I said, you need just one (1) dummy row with desired data type for every columns as explained above.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900