Reputation: 15564
I have a number of tables in my Sql Server 2014 database, which contain their primary keys defined as GUID type. I also have a number of Excel files, which I need to import into Sql Sql Server. Is there a way to generate GUID for each inserter row during SSIS Import wizard?
Upvotes: 1
Views: 560
Reputation: 176244
Solution based on Create a GUID column in SSIS
:
You can put Script Component Transformation
between source and destination.
Create new column
Edit the Script Component and goto the Inputs and Outputs tab. Expand the Output 0 and add a new column. The column type should be uniqueidentifier [DT_GUID]
.
Script Code (C#)
using System; using System.Data; using Microsoft.SqlServer.Dts.Pipeline.Wrapper; using Microsoft.SqlServer.Dts.Runtime.Wrapper; [Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute] public class ScriptMain : UserComponent { public override void Input0_ProcessInputRow(Input0Buffer Row) { // Create a Globally Unique Identifier with SSIS Row.Guid = System.Guid.NewGuid(); } }
Upvotes: 1