Sample Header Ad - 728x90

What is the best way to divide data for random groups?

2 votes
1 answer
563 views
I would like to have persisted column which will randomly group data for 32 groups according to one of varchar key column in table. My idea was: SELECT ABS(CAST(HASHBYTES('MD5',[keyColumnFromTable]) AS bigint) % 31) Questions: 1. There is any better way to do this except CHECKSUM (different values on differents COLLATE) and own functions ? 2. There will be any difference If i will use SELECT CAST(HASHBYTES('MD5',[keyColumnFromTable]) AS tinyint) % 31 ? I was reading that CAST to tinyint is taking into consideration last byte of data. Will be any affectt on randomness ?
Asked by axdna (119 rep)
Sep 8, 2020, 02:26 PM
Last activity: Sep 14, 2020, 03:55 AM