Automatic number of stored procedures

zhaozj2021-02-17  50

Create Procedure Get_BH @cl_mc char (20), @ nl_init int as begin declare @nl_cd numeric (2, 0), @ cl_lsh char (20), @ cl_lx char (1), @ nl_cdt int, @ nl_cdm int declare lshb_cursor cursor for Select Cd, LSH, Lx From LSHB Where MC = @ cL_MC Open LSHB_cursor Fetch Next From LSHB_Cursor into @ nL_CD, @ cL_LSH, @ cL_LX If @@ FETCH_STATUS = 0 begin Select @ nL_CDM = Len (RTrim (Convert (Char (10), @nl_init))))) IF @ cl_lx = '1' begin - four previous years '2000' SELECT @ nl_cdt = @ NL_CD-4 if Left (@ cl_lsh, 4) = Convert (4), getdate () , 102) / * year, serial number 1 * / begin select @ nl_cdm = len (RTRIM (CHAR (20), Convert (int, Right (@ cl_lsh, 16)) 1))) Update LSHB SET LSH = Left (@ cl_lsh, 4) Replicate ('0', @ nl_cdt- @ nl_cdm) RTRIM (Convert (20), Convert (int, Right (@ cl_lsh, 16)) 1) Where mc = @cl_mc end else if @nl_init> 1 Update lshb set lsh = replace (CHAR (4), getdate (), 102), '.', '') replicate ('0', @ nl_cdt- @ nl_cdm) RTRIM (C Onvert (10), @ nl_init) where mc = @ cl_mc else Update LSHB SET LSH = Replace (CHAR (CHART (CHAR (4), Getdate (), 102), '.', '') Replicate ('0 ', @ nl_cdt-1) ' 1 'WHERE MC = @ cl_mc end if @ cl_lx =' 2 'begin - Front six is ​​the year' 200008 'SELECT @ nl_cdt = @ nl_cd-6 if left (@cl_lsh, 4) =

Convert (4), Getdate (), 102) And Convert (INT, Substring (@ cl_lsh, 5, 2)) = DatePart (Month, getdate ()) / * Annual Moonline, serial number plus 1 * / Begin Select @ nl_cdm = len (RTRIM (CHAR (20), Convert (INT, RIGHT (@ cl_lsh, 14)) 1)))))) Update LSHB Set LSH = Left (@ cl_lsh, 6) Replicate ('0', @ nl_cdt- @ nl_cdm) RTRIM (Convert (CHAR (20), Convert (int, Right (@ cl_lsh, 14)) 1)) Where mc = @ cl_mc end else if @nl_init> 1 Update LSHB SET LSH = Replace (Convert (CHAR (7), Getdate (), 102), '.', '') Replicate ('0', @ nl_cdt- @ nl_cdm) RTRIM (Convert (CHAR (10), @ nl_init) Where MC = @ cl_mc else Update LSHB set Lsh = Replace (CHAR (7), getdate (), 102), '.', '') Replicate ('0', @ nl_cdt-1) '1' Where MC = @ cl_mc end if @ cl_lx = '3' begin - eight in front of the year '20000910' SELECT @ nl_cdt = @ nl_cd-8 if left (@ cl_lsh, 4) = convert (Char (4), getdate (), 102) And Convert (INT, Substring (@ cl_lsh, 5, 2)) = Datep Art (Month, getdate ()) and communicate (@ cl_lsh, 7, 2) = datepart (day, getdate ()) begin select @ nl_cdm = len (RTRIM (CHAR (20), Convert (CONVER) INT, RIGHT (@ CL_LSH, 12)) 1)))))))) Update LSHB Set LSH = Left (@ cl_lsh, 8) Replicate ('0', @ nl_cdt- @ nl_cdm) RTRIM (CHAR (20), Convert (int, Right (@ CL_LSH, 12)) 1)) Where mc = @ cl_mc end else ing @

NL_INIT> 1 UPDATE LSHB SET LSH = Replace (CHAR (10), Getdate (), 102), '.', '') Replicate ('0', @ nl_cdt- @ nl_cdm) RTRIM (CHAR) (10), @ nl_init) Where mc = @ cl_mc else Update LSHB set LSH = Replace (CHAR (10), getdate (), 102), '.', '') Replicate ('0', @ NL_CDT-1) '1' WHERE MC = @ cl_mc end if @ cl_lx = '4' begin - The front four is the year '00', the year uses two digits SELECT @ nl_cdt = @ nl_cd-2 if @ @@ Cl_lsh, 2) = Convert (2), getdate (), 2) / * year phase, serial number plus 1 * / begin select @ nl_cdm = len (RTRIM (CHAR (20), Convert (int, Right) @ CL_LSH, 18)) 1))))) Update LSHB SET LSH = Left (@ cl_lsh, 2) Replicate ('0', @ nl_cdt- @ nl_cdm) RTRIM (Convert (20), Convert (Int, Right (@ cl_lsh, 18)) 1)) Where mc = @ cl_mc end else if @nl_init> 1 Update LSHB SET LSH = Replace (CHAR (2), getdate (), 2), '.', ' ') Replicate (' 0 ', @ nl_cdt- @ nl_cdm) RTRIM (Convert (CHAR (10), @ nl_init)) WHERE MC = @ cl_mc else update lshb set lsh = replace (CONVERT (CHAR (2), getdate (), 2), '.', '') replicate ('0', @ nl_cdt-1) '1' Where mc = @ cl_mc end if @ cl_lx = '5' begin - the six in front of the annual month '0008', using two select @ nl_cdt = @ nl_cd-2 if left (@ cl_lsh, 2) =

Convert (2), getdate (), 2) and communic (int, substring (@ cl_lsh, 3, 2)) = datepart (Month, getdate ()) / * Annual Moonline, serial number plus 1 * / Begin Select @ nl_cdm = len (RTRIM (CHAR (20), Convert (int, Right (@ cl_lsh, 16)) 1)))))))) Update LSHB Set LSH = Left (@ cl_lsh, 4) Replicate ('0', @ nl_cdt- @ nl_cdm) RTRIM (Convert (CHAR (20), Convert (int, Right (@ cl_lsh, 16)) 1)) Where mc = @ cl_mc end else if @nl_init> 1 Update LSHB set Lsh = Replace (Convert (25), Getdate (), 2), '.', '') Replicate ('0', @ nl_cdt- @ nl_cdm) RTRIM (Convert (CHAR (10), @ nl_init) Where MC = @ cl_mc else Update LSHB set LSH = Replace (CHAR (5), getdate (), 2), '.', '') Replicate ('0', @ nl_cdt-1) '1' Where MC = @ cl_mc end if @ cl_lx = '6' begin - the six in front of the year '000910' SELECT @ nl_cdt = @ nl_cd-6 if left (@ cl_lsh, 2) = convert (2), getdate (), 2) And Convert (Int, Substring (@ cl_lsh, 3, 2)) = DatePart (Month, Get Date ()) And Convert (Int, Substring (@ cl_lsh, 5, 2)) = datepart (day, getdate ()) Begin Select @ nl_cdm = len (RTRIM (CHAR (20), Convert (int, Right (INT, RIGHT @ cl_lsh, 14)) 1)))) Update LSHB Set LSH = Left (@ cl_lsh, 6) Replicate ('0', @ nl_cdt- @ nl_cdm) RTRIM (Convert (20), Convert (int, Right (@ CL_LSH, 14)) 1)) Where mc = @ cl_mc end else if @nl_init>

1 UPDATE LSHB SET LSH = Replace (CONVERT (CONVERT (Char (8), Getdate (), 2), '.', '') Replicate ('0', @ nl_cdt- @ nl_cdm) RTRIM (CHAR (10 ), @ nl_init) Where mc = @ cl_mc else Update LSHB Set LSH = Replace (CHAR (8), Getdate (), 2), '.', '') Replicate ('0', @ nl_cdt- 1) '1' Where mc = @ cl_mc end end cover lshb_cursor deallocate lshb_cursor select lsh from lshb where mc = @ cl_mcendgo

转载请注明原文地址:https://www.9cbs.com/read-28434.html

New Post(0)