自动数字递增 [英] Auto Increment for Digits

查看:119
本文介绍了自动数字递增的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个供供应商和管理员使用的数据库,我想实现以下目标:请帮助!

管理员应使用六个字符或数字或两者的组合来提供供应商标识,但该身份仅适用于六位数字.提供该六位数后,应从系统中自动添加自动递增编号.该名称应类似于"SUPPLY-0000",类似于下一个"INDIVI-0001".这里的0000、0001应该是自动递增的.也可以通过使用存储过程来实现. BTW对该自动增量列设置了约束,以限制重复项.

查看此问题以获取答案.

自动生成-SQL Server 2005中的存储过程 [ ^ ]


在数据库中创建一个新表,该表存储一个自动递增的整数.然后,当您创建供应商时,您可以从该表中获取编号并将其附加到供应商标识中,并将其保存在供应商表中.

希望对您有帮助


I have a Database for Supplier and Administrator and I want to achieve following thing: Please Help!

The Administrator SHALL provide supplier identification with SIX characters or numbers or combination of both but this SHALL be applicable in SIX digits only. After providing that six digit then auto increment number SHALL be added automatically from system. This SHALL be like "SUPPLY-0000", similarly for next "INDIVI-0001". Here 0000, 0001 SHALL be auto increment.

解决方案

Store the digit in separate column and concatenate them when used


You can achieve that also by using stored procedures. BTW put constraint for that auto-increment column to restrict the duplicates.

Check this question for those answers.

Auto generate - stored procedure in sql server 2005[^]


Create a new table in your database that stores an auto incremented integer. Then when you create a Supplier you can get the number from that table and append it to the supplier identification and save that in the suppliers table.

Hope this helps


这篇关于自动数字递增的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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