生成服务卡会员卡号的存储过程
Posted thenext
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了生成服务卡会员卡号的存储过程相关的知识,希望对你有一定的参考价值。
ALTER PROCEDURE [dbo].[GetCard_ID] (@C_Number int=0, @C_Type FLOAT, @GETTimes varchar(30) ) AS BEGIN -- routine body goes here, e.g. -- SELECT ‘Navicat for SQL Server‘ declare @GetId int DECLARE @CARD_Ids VARCHAR(60) DECLARE @CARD_Guid uniqueidentifier set @card_guid=newid() if EXISTS(select CARD_ID from SERVER_CARD where CARD_TYPE=@C_Type and GETTIME=@gettimes ) BEGIN select @GetId=MAX(RIGHT(CARD_ID,4)) from SERVER_CARD where CARD_TYPE=@C_Type and GETTIME=@gettimes WHILE @C_Number>0 BEGIN set @getid=@getid+1 set @CARD_Ids=‘ws‘+CONVERT(varchar(100),@GETTimes,23)+replace(right(str(@GetId),4),‘ ‘,‘0‘) INSERT INTO SERVER_CARD (CARD_ID,CARD_CUSTOMER_ID,sale_guid,GETTIME) VALUES (@card_ids,0,@card_guid,@gettimes) set @C_number=@C_number-1 END END else BEGIN set @getid=0 WHILE @C_Number>0 BEGIN set @getid=@getid+1 set @CARD_Ids=‘ws‘+CONVERT(varchar(100),@GETTimes,23)+replace(right(str(@GetId),4),‘ ‘,‘0‘) INSERT INTO SERVER_CARD (CARD_ID,CARD_CUSTOMER_ID,sale_guid,GETTIME) VALUES (@card_ids,0,@card_guid,@gettimes) set @C_number=@C_number-1 END END END
以上是关于生成服务卡会员卡号的存储过程的主要内容,如果未能解决你的问题,请参考以下文章
Java 自动创建会员信息--包含用户名,卡号,密码,电话号码