如何为多个用户的每个数据库条目创建唯一ID

时间:2022-09-25 15:47:55

I am working on a c# program that will be used by 20 to 60 users concurrently. The users will input information into various text fields and select from combo boxes and then save the information to a shared database. My question is how can I create a unique ID for each entry to the database so that they can later do a search by the ID? By preference I would like the ID to be less than 8 characters or digits. The database is designed in SQL Server 2012 Express.

我正在开发一个c#程序,将由20到60个用户同时使用。用户将信息输入到各种文本字段中,并从组合框中进行选择,然后将信息保存到共享数据库。我的问题是如何为数据库的每个条目创建一个唯一的ID,以便以后可以通过ID进行搜索?根据喜好,我希望ID小于8个字符或数字。该数据库是在SQL Server 2012 Express中设计的。

Thanks for sharing!

感谢分享!

2 个解决方案

#1


5  

I think you are looking for an identity column. It would give you a unique ID for every row that is inserted. Identity columns are unique for each row and automatically increment themselves each time you create a row.

我想你正在寻找一个标识栏。它将为您插入的每一行提供唯一的ID。标识列对于每一行都是唯一的,并且每次创建行时自动递增。

Here are two resources to help you out:

这里有两个资源可以帮到你:

#2


0  

Thanks for all your posts, I was able to use an identity column which turned out great i specified the starting position in the identity column. Thanks

感谢您的所有帖子,我能够使用一个标识列,结果很好,我在标识列中指定了起始位置。谢谢

#1


5  

I think you are looking for an identity column. It would give you a unique ID for every row that is inserted. Identity columns are unique for each row and automatically increment themselves each time you create a row.

我想你正在寻找一个标识栏。它将为您插入的每一行提供唯一的ID。标识列对于每一行都是唯一的,并且每次创建行时自动递增。

Here are two resources to help you out:

这里有两个资源可以帮到你:

#2


0  

Thanks for all your posts, I was able to use an identity column which turned out great i specified the starting position in the identity column. Thanks

感谢您的所有帖子,我能够使用一个标识列,结果很好,我在标识列中指定了起始位置。谢谢