Generate UniqueIdentifier GUID in SSIS

I am using a GUID for a batch identifier in SSIS. My final output goes to SQL Server.

I know how I can generate one using Select NewId() MyUniqueIdentifier in Sql Server - I can generate one using a query and an Execute SQL task.

I am however looking to do this within a SSIS package if possible without SQL Server available.

Can I generate a GUID within SSIS?

9

2 Answers

I had a similar problem. To fix it, I created an SSIS "Composant Script" in which I created a "guid" output. The script VS C# code was the following :

Row.guid = Guid.NewGuid();

Finally, I routed the output as a derived column into my database "OLE DB Destination" to generate a guid for every new entry.

1

Simply do it in an Execute SQL Task.

  • Open the task

  • Under General -> SQL Statement, enter your query Select NewID() MyID in the "SQLStatement" field

  • Under General -> Result Set, choose "Single row"

  • Under Parameter Mapping, Enter your User::myID in Variable Name, "Input" as direction, 0 as Parameter Name, and -1 as Parameter Size

  • Under Result Set, enter "MyID" for your Result Name and type the variable in Variable Name

-Click OK

Done. Note that "MyID" is a value you can choose. EDIT: "User::myID" corresponds to the SSIS variable that you create.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like