I want to generate unique hexadecimal numbers in SQL. How can I do this?
If you know how to generate in c# please also include that.
I want to generate unique hexadecimal numbers in SQL. How can I do this?
If you know how to generate in c# please also include that.
In SQL Server: newid()
In C#: System.Guid.NewGuid()
These get you GUID's, which are unique, hexidecimal numbers; however, they tend to have dashes (-) in the middle of them, so you may have to do a bit of string parsing to get what you want. Other than that, though, this should work for you.
You could use an integer IDENTITY column and then a conver that to hex using
CONVERT(varbinary(8), MyTable.MyId)
SQL Server:
SELECT NEWID()
Oracle:
SELECT SYS_GUID()
FROM dual
MySQL:
SELECT UUID()
In PostgreSQL, you'll have to use an external function, though it has UUID
type.