Home >Database >Mysql Tutorial >SQL流水帐号的生成

SQL流水帐号的生成

WBOY
WBOYOriginal
2016-06-07 17:46:491207browse
1 --下面的代码生成长度为8的编号,编号以BH开头,其余6位为流水号。
 2 --得到新编号的函数
 3 CREATE FUNCTION f_NextBH()
 4 RETURNS char(8)
 5 AS
 6 BEGIN
 7     RETURN(SELECT ''BH''+RIGHT(1000001+ISNULL(RIGHT(MAX(BH),6),0),6FROM
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn