如何生成顺序ID V0001和A0001 [英] How to generate a sequential ID V0001 and A0001

查看:87
本文介绍了如何生成顺序ID V0001和A0001的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以指导如何为VacancyId创建顺序ID,如V0001和申请人ID,如A0001



谢谢。

解决方案

我通常建议你在每张桌子上使用内置的IDENTITY栏(你*为申请人和职位空缺做单独的表格不是吗?)



您需要格式化ID的唯一时间是向用户呈现。

它还有助于您最终获得超过9999个空缺并且必须重新格式化数字,例如V09999 - 你没有改变任何数据,只是它的显示方式


你可以看看这个并使用它有利于你:

http ://raresql.com/2013/06/21/sql-server-2012-how-to-generate-a-varchar-sequence-number-using-sequence-object/

这很简单:你需要永久存储当前值,例如使用文件或数据库(我当然只存储整数部分)并在需要时增加它。


Any one guide how to create a sequential ID For VacancyId like V0001 and Applicant ID like A0001

thanks.

解决方案

I ususally advise to just use the built-in IDENTITY column on each table (you *do* have separate tables for Applicants and Vacancies don't you?)

The only time you need to format the id is at the point of presentation to the user.
It also helps with the situation where you end up with more than 9999 vacancies and have to reformat the number e.g. V09999 - you're not changing any data, just the way it is displayed


you can have a look at this and use it to your advantage:
http://raresql.com/2013/06/21/sql-server-2012-how-to-generate-a-varchar-sequence-number-using-sequence-object/


That's pretty simple: you need to permanently store the current value, e.g. using a file or a database (I would store only the integer part, of course) and increment it when needed.


这篇关于如何生成顺序ID V0001和A0001的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆