简体   繁体   中英

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?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM