如何使用字母数字值制作数据类型? [英] how to make data types with alphanumeric value?

查看:223
本文介绍了如何使用字母数字值制作数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我只是想知道如何使具有字母数字值的数据类型,将在数据库中使用,并将其设置为主键.设置主键时通常使用的数据类型在自动编号"中,并且在使用时基本上会相应地存储编号(1 2 3 ...).可以用字母设置数据类型吗? (例如,PS0001/PS1/PS-1格式),是否会在连接了PS的情况下像自动编号一样继续设置相应的编号?

希望你能理解我的观点(尽管有点难以解释)
非常感谢!

hi folks,

i just wonder how to make the data types with alphanumeric value, that will be used in the database and will be set as the primary key. the usual data type used whenever setting the primary key is in Autonumber, and when used will basically stored numbers accordingly (1 2 3...). Could it be possible to set the data types with letters? (Ex format: PS0001/PS1/PS-1) and will continually set the numbers accordingly like Autonumber, with the PS connected to it?

hope you get my point (though kinda hard to explain it)
thanks a lot!

推荐答案

对于字母数字数据,您可以使用varchar数据类型,但是" Identity "与int/数字数据类型兼容. "身份"具有两个参数seedincrement都需要数字值.默认情况下,它们的值为(1,1).

请查看下面的链接,以获取有关"身份"的更多详细信息.

http://msdn.microsoft.com/en-us/library/ms186775.aspx

您需要在存储过程或.Net代码中为递增的字母数字值编写自定义逻辑.
For alphanumeric data you can use varchar Datatype, But "Identity" works with int/numeric Datatype. "Identity" has a two parameters seed and increment both requires numeric values. By default their values are (1,1).

Have a look at below link for more details on "Identity".

http://msdn.microsoft.com/en-us/library/ms186775.aspx

You need to write your custom logic in either Stored Procedure or .Net code for your incremented alphanumeric values.


这篇关于如何使用字母数字值制作数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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