如何使用SQL Server 2005生成类似于CS10010001的AlphaNumaric [英] How to generate AlphaNumaric like CS10010001 using SQL Server 2005

查看:94
本文介绍了如何使用SQL Server 2005生成类似于CS10010001的AlphaNumaric的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何生成

CS(year)(month)001
CS(year)(month)001
like

CS1001001 ,
CS1001002,
CS1001003,
......
...........


在SQL Server 2005中具有自动递增功能

任何人都可以将上述查询发送给我吗?

谢谢,
Chaithanya


With auto increment in SQL Server 2005

Can any one please send me the query for the above

Thanks,
Chaithanya

推荐答案

我建​​议结合使用id,getdate和datepart函数以及硬编码字符串,除非您希望001每天重新设置.然后,您需要使其更加复杂,并且不会自动生成任何内容.您必须根据当前的预付款(CS(年)(月))进行选择MAX并将其递增.

我不确定您为什么要我们不加尝试地为您编写此内容.如果您什至无法尝试,那么这也许表明您尝试的任务通常超出了您的经验水平?
I would suggest that using a combination of an id, the getdate and datepart function, and a hard coded string would do it, unless you want the 001 to reset for every new day. Then you''d need to make it a little more complex, with none of it auto generated. You''d have to do a select MAX based on the current prefex (CS(year)(month)) and increment it.

I''m not sure why you want us to write this for you without even trying. If you''re not able to even try, then perhaps that''s a sign that the tasks you''re attempting are in general beyond your experience level ?


谢谢

克里斯蒂安·格劳斯先生(MR.Christian Graus),我找到了解决方案
Thanks

MR.Christian Graus i got the solution


这篇关于如何使用SQL Server 2005生成类似于CS10010001的AlphaNumaric的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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