• This is a great idea, I am going to use it in my application. I have re-written it as a function though  (for consistency with standards of my system) by creating a view for the NEWID() function:

    CREATE VIEW v_NewID AS SELECT NEWID() AS 'New_ID'

    and modifying the code to use the view rather than NEWID()

    eg:

    -- Get the Number Items

    SET @i = ABS(@NumberItems)

    WHILE @i > 0 AND LEN(@Numbers) > 0   

      SELECT @v-2 = ABS(CAST(CAST(New_ID AS BINARY(16)) AS BIGINT)) % LEN(@Numbers) + 1

      ,    @C = SUBSTRING(@Numbers, @v-2, 1)

      ,    @Numbers = CASE

           WHEN @NumberItems < 0

         THEN STUFF(@Numbers, @v-2, 1, '')

       ELSE @Numbers

      END

      ,    @Temp = @Temp + @C

      ,    @i = @i - 1

    FROM v_NewID

    David

    If it ain't broke, don't fix it...