本文介绍了如何创建存储过程自动在表varchar()中生成数字0001-9999存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 USE [RealEstate] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER procedure [dbo]。[generate] as 声明 @ MaxValue nvarchar ( 20 ) 声明 @ LastValue nvarchar ( 20 ) 声明 @ strGUID uniqueidentifier 选择 @ MaxValue = max(RealEstateNumber)来自 @ MaxValue null set @ MaxValue = ' 0001' else set @ MaxValue = convert( int ,正确( @ MaxValue , 4 ))+ 1 set @ MaxValue = @ MaxValue + @ LastValue UPDATE [dbo] .RlRegistrationRealEstate SET RealEstateNumber = @ MaxValue WHERE GUID = @ strGUID when你在dataBase显示记录数量中插入新记录像这样0002-0003-9999 解决方案 USE [RealEstate]GOSET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER procedure [dbo].[generate] as Declare @MaxValue nvarchar(20) Declare @LastValue nvarchar(20) Declare @strGUID uniqueidentifierselect @MaxValue = max(RealEstateNumber) from RlRegistrationRealEstateif @MaxValue is null set @MaxValue = '0001'elseset @MaxValue =convert(int,right(@MaxValue,4)) + 1 set @MaxValue = @MaxValue + @LastValueUPDATE [dbo].RlRegistrationRealEstate SET RealEstateNumber=@MaxValue WHERE GUID =@strGUIDwhen you insert new record in the dataBase Display Number Of Record Like this 0002-0003-9999 解决方案 这篇关于如何创建存储过程自动在表varchar()中生成数字0001-9999存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-24 16:40