VAS
VAS

Reputation: 11

Excel destination character size in SSIS

I am trying to export data from SQL server 2008 to Excel file using BIDS. One of the fields 'DESCRIPTION' coming from SQL database is VARCHAR(4000). I can export everything to excel but the 'DESCRIPTION' field size in excel is restricted to unicode 255 and no mater what I try it does not allow me to export the data over 255 characters (exports it as blank). I tried to change SQL field as varchar(max) or ntext but none of attempts worked. I used advanced editor in BIDS on excel destination to change 'DESCRIPTION' character length manually but as soon as I hit 'OK', it resets to unicode 255. Could anybody please help me to resolve this issue?

Thanks, Vishal

Upvotes: 1

Views: 14141

Answers (8)

user19186744
user19186744

Reputation: 1

You can insert dummy data (260 characters) to under head column you want in your excel (Execute SQL Task)

Script Create and insert

CREATE TABLE `YourSheet` (`myColumn260char` LongText) 
GO 
INSERT INTO YourSheet(myColumn260char) Values('....................................................................................................................................................................................................................................................................')

And you can delete dummy row after imported.

Upvotes: 0

user18103502
user18103502

Reputation: 1

I got the same issue of the excel destination not allowing more than 255 characters. After spending almost a day, I tried adding more characters (to simplify, I added spaces more than 255) in the header of the column that has the issue with more than 255 characters. And it magically worked!

Upvotes: 0

Imran Rafique
Imran Rafique

Reputation: 339

You have to select Microsoft Excel 97-2003 and use the xls as file extension in your file name for destination.

Upvotes: 0

Glenn
Glenn

Reputation: 21

Problem: Excel only accepts 255 chars per cell when I attempt to use Excel Destination in SSIS (2008 R2) from a sql server table. SalesForce data loader would not accept CSV (with “” text qualifiers) created by ssis flat file connection manager. SalesForce will only accept CSV (with “” text qualifiers). SalesForce will accept CSV as exported by Excel (2010).

Solution: 1. Create your excel connection manager, set name/path of the destination EXCEL file in your “Excel Destination Data Flow Competent” and map meta-data. 2. Open a new Excel file, remove all extra “sheets”, rename “sheet1” to that was created in step#1, above, select all cells and format to “text”, add all the column header names to the first row of your template sheet. In the columns that need to hold more data than 255 limit, paste in any characters that exceed your limit by 50% (just in case). These columns are now configured to hold your large data. Save the file, naming it something like TEMPLATE_Excel_forLargeCellValues.xlsx 3. Copy this template into your DESTINATION connection: Before your “Excel Destination Data Flow Competent” in the SSIS Control Flow, create a new “File System Task”. Create an ssis pkg level variable to hold the path/filename of your template excel file. In your “File System Task” set “IsSourcePathVariable” = TRUE, set “SourceVariable” to User::Template_Excel. Set “IsDestinationPathVariable” = FALSE, and set “DestinationConnection” = from step #1 above. Set “Operation” = Copy file. “OverwriteDestination”=TRUE. This will now copy your formatted Excel workbook/sheet into your destination folder with the file name you designated in step #1 above and because you put a larger amount of sample data in the columns that require more than 255 chars, all your data will fit. Note: It is not necessary to delay validation on any components.

Upvotes: 2

VAS
VAS

Reputation: 11

SSIS excel engine recognizes datatype of first 8 rows and assigns it to excel source or destination automatically. Even defining the excel column as memo wont work. I tried to resolve the error by changing registry value TypeGuessRows of excel engine but it did not work either. So I was not left with any other option but to create a dummy row(2nd row) with more than 255 characters and hide it.Excel source then identify the column with unicode text stream. You have to write some logic in SSIS package to exclude this row if you are trying to import the data from excel. I heard that this issue is resolved in excel versions on and after 2010. But BIDS 2008 does not have option to choose any version after 2007 so this is the only solution if you are working with BIDS 2008 and excel.

Upvotes: 0

HMan06
HMan06

Reputation: 785

So, I did some testing. Excel data transformation is funky but I came up with a solution. I created an excel spreadsheet with fields as needed. I then created fake, dummy data in excel with character length far greater than 255 and hid the row. I then did the SSIS data transformation to the excel spreadsheet which worked. It's a weird and not preferable option but it works.

Upvotes: 3

Vanie Castro
Vanie Castro

Reputation: 309

I don't believe you can modify the Excel output column to write more than 255 characters. Why not simply write your output to a csv, it can be opened and later modified in Excel anyway.

Upvotes: 0

HMan06
HMan06

Reputation: 785

You're saying that the excel field is set to 255 right? Changing the SQL field won't have an effect on excel, you'd have to modify the excel file.

Upvotes: 0

Related Questions