Showing posts with label SSIS. Show all posts
Showing posts with label SSIS. Show all posts

Monday, September 3, 2012

DQS Exception Issues

Recently I created several SSIS packages with DQS component to do data cleansing jobs while loading data into data warehouse.  After deploying the project to the remote server, the packages failed to execute at remote server with following exception thrown:

[DQS Cleansing [2]] Error: 
Microsoft.Ssdqs.Infra.Exceptions.EntryPointException: A fatal error occurred
when trying to execute the service.at
Microsoft.Ssdqs.Proxy.Database.DBAccessClient.Exec()
at
Microsoft.Ssdqs.Proxy.EntryPoint.KnowledgebaseManagementEntryPointClient.KnowledgebaseStartBatchActivity(Int64
knowledgebaseId, String activityIdentifier)
at
Microsoft.Ssdqs.Component.DataCorrection.Logic.DataCorrectionComponent.PreExecute()
at
Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostPreExecute(IDTSManagedComponentWrapper100
wrapper)




After research and investigation for several days, I figured out that the SQL server version on my PC  is different from the remote sever which has SQL 2012 CU2.  I then upgraded my client machine to SQL 2012 CU2.

After that, some DQS packages will run inside the VSDT, some will still fail with the same exception as the diagram showed:

clip_image001

This is caused by the length of Data Quality Project Name that DQS created, which is limited to 128 characters (a combination of the package name + DQS Cleansing component name + datetime stamp + a few GUIDs).  The long project name will fail to be inserted into  [DQS_MAIN].[dbo].[A_KNOWLEDGEBASE_ACTIVITY].[KNOWLEDGEBASE_NAME].


In addition, I noticed that before CU2, the project name only append one GUID at end which allows longer SSIS package name without failing.  So, if you have experience of the DQS package failing to execute after upgrading to CU2, you may have the same problem.



image



clip_image001[9]


Solution:



  • Right click the DQS Cleansing Component to open the component property page.

  • Rename the PackageName + Name of the component to be less than 30 characters.


P.S. Change the Name of the package property or SSIS package name will not change the PackageName property inside the DQS Cleansing component.



clip_image001[5]


Now, the SSIS Package is able to run without exception on either client or remote server.

clip_image001[7] 


If you encountered the following error when you open the DQS client application, it is related to the server been upgraded without updating the DQS databases. You could run DQS installer with upgrade option in Command Prompt to resolve the issue.


image 



DQSInstaller.exe -upgrade

Special thanks to Jason H. from Microsoft for looking into my question posted on DQS Forums.


Reference:


http://social.technet.microsoft.com/wiki/contents/articles/8442.upgrade-dqs-installing-cumulative-updates-or-hotfix-patches-on-data-quality-services-en-us.aspx

Tuesday, May 29, 2012

SSIS Errors


Recently I encountered some ETL errors after deploying the SSIS packages from a single SQL server environment to a two SQL servers environment.

Error One:

Error 0x8000FFFF while preparing to load the package. Catastrophic failure.
 

Problem and Resolution:

This error message is very vague, it dese not provide enough info to figure out what's going on.  When I google it, the only clue is invalid disk address.  Since I just pushed some new packages to a new server, I suspect the client tool calling the ETL packages may not be able to locate it for some reason.
After closer examining the Parent package that hosts this package, I find this package is outside the sequence container even thought it looks like in it.  The step to replace the physical path for the package before this sequence container has been skipped and causes this error.


imageimage

 

Error Two:

The SSIS Runtime has failed to enlist the OLE DB connection in a distributed transaction with error 0x8004D025. "The partner transaction manager has disabled its support for remote/network transactions.". Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x8004D025.
A similar error could be:
System.Transactions.TransactionException: The partner transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D025) ---> System.Runtime.InteropServices.COMException (0x8004D025)
 

Problem and Resolution:

If there is a SSIS package that has the TransactionOption=”Required”, you will need to have DTC turns on.

image
image

When the package is going to be executed on a multi SQL servers environment, you will need to enable Network DTC Access on both Servers or change the SSIS TransitionOption to not be “Required” to fix the error.
Here is the step to enable the Network DTC Access:
  • Open Component Services in Administrative Tools
image
  • Expend the Computers->Expend My Computer->  to find Local DTC
  • Right Click on the Local DTC to open the property window.
image
image
 

Reference

Enable Network DTC Access

Sunday, February 26, 2012

Using Page and CAML Query to Extract SharePoint List in SSIS

 

There are several ways to read SharePoint List as data source in SSIS.  The easiest way is using the SharePoint List Adapter.  You could download it from the Codeplex site.  However, you may want to have more control during extracting the list to avoid failure, to manipulate data before sent to the output rows, or you are experiencing timeout issue with lots of item in the list. 

Here is the solution I used:

Add For Loop Container in Task Component with a Data Flow

  • Since the SharePoint list could be large, use the for loop container to loop through the paging.

image

  • Set InitExpression to the Page number @PageCount = 1
  • Set the EvalExpression to a Variable: @LoopNext  which will be determine in the data flow.
  • Set the AssignExpression to be @PageCount = @PageCount + 1

image 

Create a Script Component  with Source Type to Read SharePoint List

  • In the data flow, add a Script Component with Source type.

image

  • Pass in @LoopNext  and @SharePointPageInfo variables as Read Write Variables.
  • Pass in @SharePointSite, @SharepointListname, @SharePoinbtView, @SharePointRowLimit variables as Read Variables.
  • Create two Outputs. One for the default SharePoint list data set, the other will hold the error data.
  • Click Edit Script… button to add .net code
  • Right click the project to add Server Reference that point to the SharePoint Site

image image

  • In CreateNewOutputRows(), instantiate the SharePoint Web Service List object
  • Create several XMLNode objects as the parameters to call System.Xml.XmlNode GetListItems()
//Retrieve the list of available fields from the GetList call to Sharepoint.
Lists SPS = new Lists();
SPS.UseDefaultCredentials = true;
SPS.Url = strSharepointURL;
 
//Create XML Node
XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlNode ndViewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
XmlNode ndQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");
XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query","");
 
 
XmlNode ndListItems = null;
ndListItems = SPS.GetListItems(strListName, strViewName, ndQuery, ndViewFields, strRowLimit, ndQueryOptions, null);



  • Once the result gets back, iterate through the XML nodes to populate the default output data row.
  • If there is an exception thrown

    • Set the @LoopNext to false which will stop the For Loop container
    • Add a row that contains the exception message to error output.


catch (System.Web.Services.Protocols.SoapException ex)
     {
         string strError = "Message:" + ex.Message + "\nDetail:" + ex.Detail.InnerText + "\nStackTrace:" + ex.StackTrace;
         
         ErrorBuffer.AddRow();
         ErrorBuffer.ErrorData = strError.ToString().Substring(0, strError.ToString().Length > 4000 ? 4000 : strError.ToString().Length);
         bLoopNext = false;
     }



  • In the data flow, sent the SharePoint list items to the destination table and the error data to error table. This way the SSIS package will not fail to execute with any SharePoint Site issue. Other process could utilize the data in the error table to recover it softly.
  • In the Add Metadata component, add the @PageCount as an output column. It could be used for recovery or debug purpose.

image 


Narrow Down the Needed Fields



Don’t select all the fields from the list. Sometime the list may contain binary data, meta data or image that may take long time to load. To narrow down the fields, just specify the fields in the ViewFields XML Node as:



XmlNode ndViewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
//Get List of Field needed
ndViewFields.InnerXml = "<FieldRef Name='ID' />";
ndViewFields.InnerXml += "<FieldRef Name='Created' />";
ndViewFields.InnerXml += "<FieldRef Name='Author' />";
ndViewFields.InnerXml += "<FieldRef Name='Editor' />";
ndViewFields.InnerXml += "<FieldRef Name='Modified' />";

Add CAML Query to Extract Only the Delta



To pull only the delta records in, just add filters in the query. The SharePoint list has a system field called “Modified” which will be time stamped when the record get changed. You could utilize the CAML query to get the items that have Modified Date greater than a Date value or within an arrange of date. If you don’t know the syntax of the CAML Query, you could use some SharePoint Utility such as U2U CAML Builder.


Here is a sample CAML Query that will filter the result by range of date:



<Where><And>
<Geq><FieldRef Name="Modified" IncludeTimeValue="TRUE" /><Value Type="DateTime">2012-01-01 00:00:00</Value></Geq>
<Leq><FieldRef Name="Modified" IncludeTimeValue="TRUE" /><Value Type="DateTime">2012-01-31 23:59:00</Value></Leq>
</And>
</Where>


Page though Large Number of List Items in the Script



Depend on the size of the item, you may set the row limit to 1000 while calling the GetListItems().  The function supports service-side paging. When the XML result returned, it includes a ListItemCollectionPositionNext attribute that contains the information to support the paging.  You need to save it for the next call.  Make sure you do not modify the string. 


In the example below, I set the ListItemCollectionPositionNext attribute to a local variable first and the bLoopNext to true. I then save the string to a SSIS Read/Write variable to be use for next loop.



//Get page related meta data
XDocument meta = XDocument.Parse(ndListItems.InnerXml);
if (meta.Root.Attribute("ListItemCollectionPositionNext") != null)
    {
       strPage = meta.Root.Attribute("ListItemCollectionPositionNext").Value;
       bLoopNext = true;
    }
else
    {
       strPage = string.Empty;
       bLoopNext = false;
    }

When next loop starts, I set the saved attribute string to the QueryOptions parameter to be used to fetch the next set data back.



//Set page Query option
if (strPage.Length > 0)
    {
       ndQueryOptions.InnerXml = @"<Paging ListItemCollectionPositionNext='' />";
       ndQueryOptions.ChildNodes[0].Attributes["ListItemCollectionPositionNext"].InnerText = strPage;
    }
else
    {
        ndQueryOptions.InnerXml = "";
    }
    

 Result



After executing the SSIS package, you can see the SharePoint List been extracted page by page as below:


image 


The PageCount column stores the SharePoint List page number.


Reference:



http://msmvps.com/blogs/ivansanders/archive/2011/07/24/ssis-sharepoint-list-adapters.aspx


http://msdn.microsoft.com/en-us/library/lists.lists.getlistitems(v=office.12).aspx


http://sqlsrvintegrationsrv.codeplex.com/releases/view/17652

Thursday, February 16, 2012

Tip to Change SSIS Variable Scope

Recently I work on a SSIS project that has a Sequence Container with lot of variables that I need for a data flow. Later on I want to change the sequence container to be a For Loop Container.   It is easy to copy and paste the the data flow in the container to the other. But, how to move the SSIS variables in the visual studio?

If you are familiar with the SSIS XML code, you may be able to copy or move the variables from one XML Node section to the other without corrupt it.  For others, recreating the variable with correct value or expression could be cumbersome.

Here is a easy way to handle it:

  • Install BIDS Helper from CodePlex site.
  • Select the variable you want to copy or move

image

  • Click on the Move/Copy Variables from SSIS Variables tool bar to open a new window

image

  • Click on the DTS executable that you want the variable scope to change to , then click OK

image

  • The variable shows up in the SSIS Variables Window with new Scope

Thursday, January 12, 2012

SQL Server 2012 – Integration Services Catalog

SSIS in SQL 2012 has a new Integration Services Catalog (SSISDB) that is used for monitoring and managing SSIS projects. The Catalog will store all the integration services objects and will automatically log all the package execution activities when the SSIS project is using the new Project Deployment Model.

In order to use the new Project Deployment Model, you need to create the Integration Services Catalog for the first time.  Otherwise you will get the following error message as:

An Integration Services catalog (SSISDB) was not found on this server instance ("LocalHost").
To deploy a project to this server, you must create the SSISDB catalog. Open the Create Catalog dialog box from the Integration Services node.

image

Steps to Create the Catalog:

  • Open SQL Server Management Studio
  • Right click on the Integration Services node
  • Click on the Create Catalog…..

image

  • The catalog name is SSISDB. Enter the password for encryption then hit the OK button.

image

  • The new SSISDB will be created and show in two places:
    • Database node
    • Integration Services node

image 

  • You may view or adjust the catalog properties using the property window or Catalog.Configure_Catalog stored procedure.

image

Monitor the Execution Activities

After deploy a SSIS project, the data will be collected by the SSISDB.  The build in Integration Service Dashboard could be used to monitor all the activities that executed by the SSIS packages for that project.

  • Right Click on the SSISDB node to open the Reports->Standard Reports->Integration Services Dashboard.

image

  • Dashboard Summary Report opened.

image

  • There are hyperlinks on the overview report to navigate to more detail information.

image

There is no need to create any custom logging in the SSIS packages at all.

Additional Reference:

http://msdn.microsoft.com/en-us/library/hh479588(v=SQL.110).aspx

Monday, January 10, 2011

SSIS Error Loading Excel Data with Office 2010 installed

Recently I am setting up a virtual machine to play with the new SQL Server “Denali”. The latest Office 2010 applications and Visual Studio 2010 also have been installed on it.  I open a SSIS project and create an Excel Connection Manager with default version set to Microsoft Excel 2007 to load a excel spreadsheet that was saved as *.xlsx format .
When I  use this newly created Excel Connection Manager as the Data Source in my data flow, I got the following error after click the Preview button:
image
The SSIS error log has following:
SSIS Error Code DTS_E_OLEDB_NOPROVIDER_ERROR.  The requested OLE DB provider Microsoft.ACE.OLEDB.12.0 is not registered. Error code: 0x00000000.  An OLE DB record is available.  Source: "Microsoft OLE DB Service Components"  Hresult: 0x80040154  Description: "Class not registered".
People will normally assume that the machine should contains the latest data provider (Office 2007 provider(12)), when the Office 2010 Excel/Access application installed on the machine. Unfortunately, it is not the case.
There are two ways to resolve this issue:
    1. Install the latest office driver form the following link: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=7554F536-8C28-4598-9B72-EF94E038C891&displaylang=en
    2. Save the Excel spreadsheet to be Microsoft Excel 97-2003 (*.xls) format to load the data in.

Monday, August 30, 2010

Using SSIS Batch Destination component to load the SCD Dimension Table

The SSIS Batch Destination component could be used to populate the SCD Type 1 or Type 2 table very easily.
image
  • Create an ADO.NET connection manager to be used.
  • Click on the Input Columns tab to select all the input columns needed.
  • Go to the Properties tab to write the TSQL merge statements.
 image
  • Type in the table name in the Working Table textbox. You may use a temporary table (denoted as #) or a regular table to hold your input data.
  • Type in the merge statements in the SQL Command textbox. The Batch Destination component supports multiple SQL Commands in a transaction.
  • For SCD Type 1 table, you may use the following TSQL statement to do both update or insert.
MERGE INTO DW.TableName AS T
USING 
#TableName AS S
ON T.ID = S.ID
/*Update Record*/
WHEN MATCHED AND S.UpdateFlag = 1
THEN UPDATE 
SET
.......
 
T.Column1=S.Column1,
T.Column2=S.Column2,
T.Column3=S.Column3,
T.Column4=S.Column4
/*Insert record : New record or type 2 current record*/
WHEN NOT MATCHED BY 
TARGET THEN INSERT 
(
ID,
Column1,
Column2,
Column3,
Column4,
... )
VALUES(
S.ID,
S.Column1,
S.Column2,
S.Column3,
S.Column4,
 
...);
  • For SCD Type 2 table, you may use the following TSQL statements to do update, insert, expire, and update type 1 columns in historical data.
MERGE INTO DW.TableName AS T
USING 
#TableName AS S
ON T.ID = S.ID
/*Update Record*/
WHEN MATCHED AND S.UpdateFlag = 1
THEN UPDATE 
SET
.......
 
T.Column1=S.Column1,
T.Column2=S.Column2,
T.Column3=S.Column3,
T.Column4=S.Column4
/*Insert record : New record or type 2 current record*/
WHEN NOT MATCHED BY 
TARGET THEN INSERT 
(
ID,
Column1,
Column2,
Column3,
Column4,
... )
VALUES(
S.ID,
S.Column1,
S.Column2,
S.Column3,
S.Column4,
 
...);
 
/*Expire type 2 existed Record*/  
MERGE INTO  DW.TableName AS T
USING    #TableName AS S
ON     T.ID = S.D
WHEN MATCHED AND S.UpdateFlag = 0 
THEN UPDATE SET
T.EffectiveEndDate = GetDate(), T.CurrentRecord ='NO'
;
/* Update Type 1 columns in the expired records */
UPDATE  T    
SET X.Type1Column1 =  S.Type1Column1, 
X.Type1Column2 =  S.Type1Column2 
FROM DW.Tablename AS X INNER JOIN DW.TableName AS S    
ON X.NK= S.NK /*Join table with Natural keys */    
WHERE S.CurrentRecord = 'YES' 
AND S.ID >  X.ID
;
There are some performance issues you may encountered while working with large table, so you will need to change the Rows Per Batch or Max Commit Size properties accordingly. Sometime you may find that creating an index in your temporary table could improve the performance of this load.