We have a table named
product info in that Product ID is uniqueidentifier
column and it is a primary key. We are getting the flat file which is having
the product name list and we need to load it.
Below is the table structure.
CREATE TABLE Product_Info(
product_ID
uniqueidentifier NOT
NULL primary key,
Product_name
varchar(100) NULL
)
|
Below is the file
In SSIS
we don’t have any transformation which directly generates the random generate
the uniqueidentifier number. For generating the GUID number we need to use C#
code.
Let’s see this demo.
I am taking DFT and taking the source as Flat file and
configuring this.
Now I am taking a script component and selecting it as
transformation.
Now we need to create one output column.
And setting data type as Uniqueidentifier.
Now we need to click on the edit script and write the C# code
to generate the new GUID number.
Below is the C# code.
public override void
Input0_ProcessInputRow(Input0Buffer Row)
{
Row.Guidnumber =
Guid.NewGuid();
}
|
Save and close this.
Now I am taking oledb destination and configuring it.
Now the package is ready for a run.
Before running this package records in the table.
Now running this package.
See the records in the table.
GUID value is generated successfully.
No comments:
Post a Comment
If you have any doubt, please let me know.