Would this be reliable for using as an ID for data storage(SQL Server)?
I would use a guid but I prefer a numeric value.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No. GUIDs are 128-bit but hashcodes are 32-bit. Therefore, there are necessarily collisions. It may be unlikely that you ever encounter one, but you are not guaranteed to never encounter one.
What you want for reliability is a guarantee that you never encounter a collision. If you insist on using
Guid.NewGuid().GetHashCode()then you need to add logic to detect collisions. GUIDs do have advantages (and disadvantages) but without additional information I would suggest using an auto-incrementingintcolumn. Especially as you say you want a numeric column I would lean towards using anIDENTITY.