Good Morning,
I was looking for a way to combine two integers to create a unique number, I have two tables that I need to combine into a third table with unique numb
Similar to Magnus Hoff, but I would recommend using a binary friendly approach instead of a base 10 approach.
combinedid = (classid << 8) + schoolid;
And then, later:
classid = combinedid >> 8;
schoolid = combinedid & 0xFF;
I think this is a little more straight forward from a programming standpoint (making it clear that your school ID is 1 byte (0-255), the class ID is 3 bytes).
You could also easily do this with a bigint (Long / Int64), making two int32's a single int64 safely:
combinedid = ((long)classid << 32) + schoolid;