Hi
Challenge
I am trying to write an SSIS package to export an SQL Table Data to Excel
- Table has 8 Columns , Transactionid INT,Currency CHAR(3),CustomerId INT,CustomerName NVARCHAR(50),Paymentdate DATE,Amount DECIMAL(25,2),rectypeId INT,PaymentDesc NVARCHAR(25)
- Each sheet in Excel will illustrate data broken out by Customer ID & Currency
- Excel Sheet name will be a concatenation of Customer ID and Currency i.e. 12234 USD
What I am Working from so far
- http://visakhm.blogspot.ie/2013/09/exporting-sqlserver-data-to-multiple.html
- https://social.msdn.microsoft.com/Forums/sqlserver/en-US/2421d9aa-5347-4f24-a78b-da02eb644f5f/export-sql-server-table-into-multiple-sheets-in-excel?forum=sqlintegrationservices
- http://www.bidn.com/blogs/KeithHyer/bidn-blog/2512/creating-excel-worksheets-dynamically-in-ssis
All the above are the closest examples I have come across but all examples online I have seen are in 05/2008 VS so difficult to translate to 2012 but I have the concept and the structure setup in 2012
My issue is , I am getting very generic error messages when I try to execute what I have wrote based on the above it is difficult to dev in 2012 and be 100% I have all the configuration setup , plus the posts above are not very detailed.
If anybody knows of any other detailed examples please send on :) I have spent a few hours searching now and reading
Example of my Frustration
For simplicity , I am just trying to illustrate by Customer ID , add in the Currency grouping later
SQL Task to generate sheet list . This task will execute SQL script to get distinct list of CustomerID's from table. This will then be stored in a object variable for use within the loop to create the sheets.
Issue
I can this to work returning a single Result set but trying to return the Full result set is when I get issues
- https://msdn.microsoft.com/en-us/library/cc280492.aspx
- https://www.simple-talk.com/sql/ssis/implementing-foreach-looping-logic-in-ssis-/
I have verified against the above examples , i.e. If the result set type is Full result set or XML, you must use 0 as the result set name.
Error I receive :
- [Execute SQL Task] Error: Executing the query "SELECT Distinct CustomerId FROM [Payments].Externa..." failed with the following error: "The type of the value (DBNull) being assigned to variable"User::CustID" differs
from the current variable type (Int32). Variables may not change type during execution. Variable types are strict, except for variables of type Object.
". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
43510
48598
Sql Task Editior setup
The User::CustID DataType is an Int32
Full result set
Result set:Result Set Name = 0 , Variable name : User::CustID
Query is SELECT Distinct CustomerId FROM [Payments].ExternalPostPaymentsRecCarlo ,No NULLS are returned
Result Set returned is
4351048598