在sql Server 2008中自动增加否? [英] Auto increment no in sql Server 2008?
本文介绍了在sql Server 2008中自动增加否?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要那种格式的身份证号码
E001
E002
E003
但它是否自动递增而不是由用户插入?
I Want the ID no in that format
E001
E002
E003
but it in auto increment not to insert by user?
推荐答案
从这里开始: http://www.sqlteam.com/article/custom-auto-generated-sequences-with-sql-server [ ^ ]
检查一下:自动生成AlphaNumeric ID in SQL Server表 [ ^ ]
阅读本文: HTTP://www.s qlteam.com/article/custom-auto-generated-sequences-with-sql-server [ ^ ]
专注于选项2(将其作为演示文稿问题)...
身份字段之间的标识符行之间的所有差异都是前面的E字母,以及您使用前导零填充固定长度的数字...
这只是一个视觉表示并没有真正增加数字的唯一性 - 这意味着如果你删除那些部分(E和前导零)你仍然有一个唯一的数字...
我的建议是去解决方案 - 使用标识列并在向最终用户呈现时对其进行格式化...
Read this article: http://www.sqlteam.com/article/custom-auto-generated-sequences-with-sql-server[^]
Concentrate on option 2 (Make it a presentation issue)...
All the difference between your line of identifiers between a identity field is the preceding E letter and the fact that you pad your number with leading zeroes to a fixed length...
That's only a visual representation and not really add to the uniqueness of the number - it means that if you remove those parts (E and leading zeroes) you still have a unique number...
My suggestion is to go with such a solution - use identity column and format it when presenting to end user...
这篇关于在sql Server 2008中自动增加否?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文