CREATE PROCEDURE Proc_LSH
AS
BEGIN
SET NOCOUNT ON;
DECLARE @MAX_ NVARCHAR(100)
select @MAX_=(right(max(FR_NO),4)+1) from 资料表 where left(right(FR_NO,12),8) = CONVERT(NVARCHAR(10),GETDATE(),112)
SET @MAX_= 'XXX'+ CONVERT(nvarchar(10),GETDATE(),112) +'0000'+CONVERT(NVARCHAR(100),ISNULL(@MAX_,'0'))
-----这个应该直接改成 SET @MAX_= 'XXX'+ CONVERT(nvarchar(10),GETDATE(),112)+CONVERT(NVARCHAR(100),ISNULL(@MAX_,'0'))
INSERT INTO 资料表(FR_NO) values(''+CONVERT(NVARCHAR(100),@MAX_)+'')
END
GO
---