The newid returns a 16-byte guid, so you might try making it 16, but I suspect the problem has to do with the modulo operator. Even so, I would not have expected that high a percentage of dups. I did the following experiment which sort of confirms that theory. Do you always have to have a ten-digit number?-- Inserting GUIDs generated by newid() into a temp table.if OBJECT_ID('tempdb..#tmp') is not null DROP TABLE #tmp;CREATE TABLE #tmp (id uniqueidentifier);WITH N(n) AS( SELECT 1 UNION ALL SELECT n+1 FROM N WHERE n <= 100000)INSERT INTO #tmp SELECT newid() FROM N OPTION (MAXRECURSION 0);-- check if there are any dups in the GUIDs. (no dups in my tests)SELECT id,COUNT(*) FROM #tmp GROUP BY Id HAVING COUNT(*) > 1 -- returns no dups-- are there dups when cast to 10 digit int (4-10 dups in my test)select cast(CAST(id AS VARBINARY(5)) AS BIGINT)%1000000000+1000000000, COUNT(*) FROM #tmpgroup by cast(CAST(id AS VARBINARY(5)) AS BIGINT)%1000000000+1000000000HAVING COUNT(*) > 1-- are there dups when cast to bigint ? (none in my tests).select cast(CAST(id AS VARBINARY(16)) AS BIGINT), COUNT(*) FROM #tmpgroup by cast(CAST(id AS VARBINARY(16)) AS BIGINT)HAVING COUNT(*) > 1