DECLARE @listno VARCHAR(100)<br /> DECLARE @currlistno VARCHAR(100)<br /> DECLARE @max INT<br /> SET @max = 0<br /> SET @listno = 'XJ'+replace(CONVERT(VARCHAR(10),GETDATE(),120),'-','')
SELECT @currlistno = MAX(xjno) FROM yw_xunjian WHERE xjNo LIKE @listno + '%'<br /> if(isnull(@currlistno,'') != '') SET @max = CONVERT(INT, RIGHT(@currlistno,4))<br /> SET @listno = @listno + right(10000+ @max + 1,4)
SELECT @listno