Hi,
I've created an SSIS 2008 package that contains several data flow tasks. Each tasks takes data from a SQL Server 2008 database, runs a select statement to gather the data and inserts the data into a comma delimited flat file.
When I run the package, I receive the following error:
[Customers Flat File [196]] Error: Data conversion failed. The data conversion for column "LastName" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".
I've researched this and adjusted the package such that the input field length is now 100 and any bad rows are being sent to a separate file. The error still persists.
In SSMS, I wrote a query:
SELECT MAX(LEN(dbo.Customer.LastName)), dbo.Customer.LastName from dbo.Customer group by LastName order by MAX(LEN(dbo.Customer.LastName)) desc
This returns records with the longest length of 26, well below the 100 set as my input field length in SSIS.
The query I'm running in SSIS data flow is as follows:
SELECT dbo.Customer.Email, LEFT(dbo.Customer.FirstName, 100) AS FirstName, LEFT(dbo.Customer.LastName, 100) AS LastName, dbo.Customer.Gender, dbo.Customer.DateOfBirth, dbo.Address.Zip, dbo.Customer.CustomerID, dbo.Customer.IsRegistered FROM dbo.Customer INNER JOIN dbo.Address ON dbo.Customer.CustomerID = dbo.Address.CustomerID INNER JOIN dbo.Orders ON dbo.Customer.CustomerID = dbo.Orders.CustomerID WHERE (dbo.Orders.OrderDate >= CONVERT(DATETIME, '2009-01-01 00:00:00', 102)) GROUP BY dbo.Customer.Email, LEFT(dbo.Customer.FirstName, 100), LEFT(dbo.Customer.LastName, 100), dbo.Customer.Gender, dbo.Customer.DateOfBirth, dbo.Address.Zip, dbo.Customer.CustomerID, dbo.Customer.IsRegistered
What must be done to correct either the data flow or the query therein so that the error is resolved?
Thanks,
Sid