Wednesday, December 9, 2009

Load MS Access data to SQL server

Question: How to transfer MS Access data to Sql Server 2005?

There are 2 ways for achieving this
1) SSMS: Import & Export Wizard
2) BIDS: Create a New SSIS package

First approach is easy and gives you flexibility to modify the SSIS package(If required)
I hope you can try this your self .

Let me know if you need my help for this.

Second approach: 
Open the BIDS and create a new package

a) Create a new OLE DB Source connection.
b) Select the provider as "Native OLE DB\ Microsoft Jet 4.0 OLE DB Provider".
c) Select the Database file name. [Check the Image Below]

a) Take a DFT.
b) In DFT drag "OLE DB Source", "OLE DB Destination" [or take any destination as per your requirement]
[Check the Image below]

Before executing the package please makes sure that destination table should have the correct data type. [if not use data conversion task]

I hope this will help you. If you need more assistance or clarification, please leave the comment.

Monday, November 23, 2009

What is Factless Fact table?

Today, I faced an interview for MSBI Developer. The guy asked me many questions and most of them i answered perfectly. The Guy asked me a question on factless fact table. I like to share it with you, if you are not already familiar with it.

Question: What is FACTLESS Fact table?

The “Factless Fact Table” is a table which is similar to Fact Table except for having any measure; I mean that this table just has the links to the dimensions. These tables enable you to track events; indeed they are for recording events.

Factless fact tables are used for tracking a process or collecting stats. They are called so because, the fact table does not have aggregatable numeric values or information. They are mere key values with reference to the dimensions from which the stats can be collected

Tuesday, October 6, 2009

Delete bunch of dynamic files

Question: How to delete all files from a directory?

Answer: Please follow the following steps:

Step1: Add a For each loop container. & Inside it add a File system task.

Step2: Add 2 variables (Scope: Package level)
  1. Var_FilePath
  2. Var_InputFolder

Step3; Double click on Foreach loop container and in expression map the "Directory" property to Var-InputFolder. (Click on the image for larger view)

Please select the "Reterive file name" property to fully qualified.

Step4; Map the Var_FilePath in variable mapping tab.

Step5: Double click on File system task and change the operation to "Delete file" and Set IsSourcePathVariable property to TRUE. Then map your Var_FilePath to it. (Click Image)

Step6: Now select the File System Task and press F4 for property window. Set the "Delay validation" to True.

Step7: Execute your package.

Hope this will help you.


Allocating a 'Set ID' & Extracting data in groups

Allocate a Set ID for a Batch of data and make a group.
Retain Values from Previous Rows.

Following is the input data and desired output for that


Drag a DFT in the control flow and add the following components.

For achieving this you need to use Script Component in DFT. and the following below steps: Before that you need to select Header as input column.

Create an output column in script component

Add the following code in the Script component.
Imports System
Imports System.Data
Imports Microsoft.SqlServer.Dts.Runtime
Public Class ScriptMain
Inherits UserComponent
Dim int_Sno as integer ' // this variable should be global for the script (class level)
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
If Row.RecType = "A" Then
int_Sno = int_Sno + 1
End If
Row.Sno = int_Sno

Catch ex As Exception
End Try
End Sub
End Class

Now execute your package and you will get the desired output (Given below)

Hope this will help you.

Friday, August 14, 2009

Excel destination - cannot convert between unicode and non-unicode

While using the Excel Destination we used to get following error:
Error1 Validation error. Data Flow Task: Excel Destination [1311]: Column "Order Date" cannot convert between Unicode and non-Unicode string data types.

OLE DB source query:
where order_date data type is datetime in DB. Here we are converting to varchar

DFT (OLE DB Source and Excel destination)

Table structure:

I checked on MSDN for excel destination. Here is some content written about moving data for your reference: Data types. The Excel driver uses only six data types, which Integration Services maps as follows: · Numeric – double-precision float (DT_R8) · Currency – currency (DT_CY) · Boolean – Boolean (DT_BOOL) · Date/time – date (DT_DATE) · String – Unicode string, length 255 (DT_WSTR) · Memo – Unicode text stream (DT_NTEXT)

Integration Services does not implicitly convert data types. for resolving this problem please follow these steps.

Step1: Add Data Conversion task between Source and Excel destination

Step2: Edit the data conversion task and change the data type to [DT_WSTR], change the length if required.

Step3: After adding the data conversion, the error message will go. Execute your package.

It will create an Excel file and load the data.

Monday, July 20, 2009

How to include Primary ID column using SSIS package?

I have target table where columns are ID, Name & DateofBirth where ID is PK and should be increment of 1(eg. 1, 2, 3, 4... and so on) also NOTE that ID column is NOT AN IDENTITY column

Now I have flat file which has data with only Names & Dateofbirth.


Hi, There are two ways.

First:: Download the "Row Number Transformation" and use it in your SSIS package.

The Row Number Transformation calculates a row number for each row, and adds this as a new output column to the data flow. The column number is a sequential number, based on a seed value. Each row receives the next number in the sequence, based on the defined increment value.

Second:: Add a "Script Component transformation" and write a script there for adding the row numbers. Please check the "Row Numbers in a DataFlow"for step-by-step explanation.


The main motto of this blog is to share my knowledge and experience with you.