/*
Requirement:
Application number should be 10 char
Application Number first firve char year + julian date, rest of 5 number will be sequence number
*/
DECLARE @APPLN_NUM as int;
-- This will be maximum number in table - to be selected
SET @APPLN_NUM = 1822500001 -- if you comment this line, first number will be generated
IF (@APPLN_NUM) is null
BEGIN
SELECT CONVERT(VARCHAR,right(DATEPART(yy, getdate()),2)) + CONVERT(VARCHAR,DATEPART(dy, getdate())) + '00001';
END
ELSE
BEGIN
SELECT CONVERT(VARCHAR,right(DATEPART(yy, getdate()),2)) + CONVERT(VARCHAR,DATEPART(dy, getdate())) + right(@APPLN_NUM,5) + 1
END
Requirement:
Application number should be 10 char
Application Number first firve char year + julian date, rest of 5 number will be sequence number
*/
DECLARE @APPLN_NUM as int;
-- This will be maximum number in table - to be selected
SET @APPLN_NUM = 1822500001 -- if you comment this line, first number will be generated
IF (@APPLN_NUM) is null
BEGIN
SELECT CONVERT(VARCHAR,right(DATEPART(yy, getdate()),2)) + CONVERT(VARCHAR,DATEPART(dy, getdate())) + '00001';
END
ELSE
BEGIN
SELECT CONVERT(VARCHAR,right(DATEPART(yy, getdate()),2)) + CONVERT(VARCHAR,DATEPART(dy, getdate())) + right(@APPLN_NUM,5) + 1
END
No comments:
Post a Comment