如何在sql server中生成自动增量id号 [英] how to generate auto increment id number in sql server

查看:103
本文介绍了如何在sql server中生成自动增量id号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在sql server中生成自动genarete id号,



我需要添加我的From Auto增加ID号。我的id号格式是

INV001。如何获得这种身份证号码。





我用这个。只有Numbers.i需要带有字符的ID号。

how to generate auto genarete id number in sql server,

I need a adding my From Auto increment ID number.My id number Format is
INV001.How to genarete a this kind of id Number.


I use this one .It only Numbers.i Need a ID number with character.

CREATE TABLE Persons
(
  ID int IDENTITY(1,1) PRIMARY KEY,
  PRIMARY KEY (ID)
)





任何人都可以帮助我。谢谢你



Anyone can help me.Thank You

推荐答案

http://forums.asp.net/t/1920621.aspx [ ^ ]



< a href =http://www.c-sharpcorner.com/forums/thread/218080/auto-increment-of-alphanumeric-number-using-C-Sharp.aspx> auto-increment-of-alphanumeric-number -using-C-Sharp.aspx [ ^ ]


创建表人



ID int NOT NULL AUTO_INCREMENT,

PRIMARY KEY(ID)

CREATE TABLE Persons
(
ID int NOT NULL AUTO_INCREMENT,
PRIMARY KEY (ID)
)


试试这个



右键单击要添加增量和转到设计模式的表格。

选择主键并查看下面

你可以看到身份规范中的+使得为是并点击那个+

并选择增量即。 1,2,3并选择身份种子1,2,3或其他任何你喜欢



身份种子意味着你要开始的点和身份增量是你希望增加的价值



例如。如果您选择2作为身份增量,5作为身份种子,那么输出将是

5

7

9



例如。如果你选择1作为身份增量而1作为身份种子那么输出将是

1

2

3
Try This

Right Click on table you want to add increment and goto design mode.
Select the primary key and see below
You can see + in Identity Specification make that yes and click on that +
and select the increment ie. 1,2,3 and select the identity seed 1,2,3 or whatever u like

identity seed means the point you want to start from and identity increment is the value that you like to increment by

for eg. if you select 2 as identity increment and 5 as identity seed then the output will be
5
7
9

for eg. if you select 1 as identity increment and 1 as identity seed then the output will be
1
2
3


这篇关于如何在sql server中生成自动增量id号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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