How can I update the value of a field in a table to be a random number that's unique most of the time?
<p>I have a simple table:</p>

<pre><code>CREATE TABLE [dbo].[Word] (
    [WordId]        INT            IDENTITY (1, 1) NOT NULL,
    [NameId]        INT            NOT NULL
    PRIMARY KEY CLUSTERED ([WordId] ASC)
);
</code></pre>

<p>I have a unique index on NameId</p>

<p>I am trying to update this table and change one column to a random number:</p>

<pre><code>UPDATE Word SET NameId = ROUND(RAND()*2147483647,0)
</code></pre>

<p>I realize there is a very very small chance this will not work but it's actually failing every time even though the table has only a very small number of rows the update always fails and says there's a duplicate. </p>

<p>Can anyone tell me what's happening here and also suggest a way to update this table so that there's no duplicate values of NameId created most of the time. </p>