标签:
USE [WJKC]
GO
/****** Object: StoredProcedure [dbo].[Address_GetCode1] Script Date: 2016/3/29 星期二 下午 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(20) output--@DZ nvarchar(250),@ISTY int,@DETAIL nvarchar(250)
AS
BEGIN
--取出最大CODE
SET @CODE=NULL
SELECT TOP 1 @CODE=CODE from SHDZ
ORDER BY CODE DESC
--如果没取出来
IF @CODE IS NULL
BEGIN
SET @CODE=‘01‘
END
ELSE
BEGIN
DECLARE @NUM VARCHAR(2)
--取出编号+1
SET @NUM=CONVERT(VARCHAR,(CONVERT(INT,RIGHT(@CODE,2))+1))
SET @NUM=REPLICATE(‘0‘,2-LEN(@NUM))+@NUM
SET @CODE=@NUM
END
END
标签:
原文地址:http://www.cnblogs.com/wenjieyatou/p/5335111.html