Use [WJKC]
GO
/****** object:storedprocedure [dbo]. [Address_getcode1] Script date:2016/3/29 Tuesday 10:20:47 ******/
SET ANSI_NULLS on
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
--Author: <Author,,Name>
--Create Date: <create date,,>
--Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo]. [Address_getcode1]
--Add The parameters for the stored procedure here
@CODE nvarchar [email protected] nvarchar (+), @ISTY int, @DETAIL nvarchar (250)
As
BEGIN
--Remove the maximum code
SET @CODE =null
SELECT TOP 1 @CODE =code from SHDZ
ORDER by CODE DESC
--if not taken out.
IF @CODE is NULL
BEGIN
SET @CODE = ' 01 '
END
ELSE
BEGIN
DECLARE @NUM VARCHAR (2)
--Take out the number +1
SET @NUM =convert (VARCHAR, (CONVERT (Int,right (@CODE, 2)) +1))
SET @NUM =replicate (' 0 ', 2-len (@NUM)) [email protected]
SET @[email protected]
END
END
SQL stored procedure generation sequential encoding