'How do I insert a UniqueID into multiple rows in SQL with Coldfusion?

I've created a new table (subscribers) and am pulling the email address from another table (MailingList). I'm also inserting a flag Sub and a UserID.

The Sub flags whether the user is active or not, while the UserID will be used in a URL to identify the user who chooses to unsubscribe.

My problem is when running the query, the #createUUID()# is the same in every record.

How can I create UNIQUE IDs?

<cfquery name="LoadSubs"  datasource="#dsn#">
    INSERT INTO subscribers (email, Sub, UserID)
    SELECT 
        email, 
        <cfqueryparam cfsqltype="cf_sql_bit" value='1'>, 
        <cfqueryparam cfsqltype="cf_sql_varchar" value='#createUUID()#'>
    FROM MailingList;
</cfquery>


Solution 1:[1]

OK... so I inserted NewID() as uniqueindetifier and then converted uniqueindetifier to varchar(300) and it worked. Not sure if it's the best approach, but the result is what I needed.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MJRoz