打印本文 打印本文 关闭窗口 关闭窗口
自动编号的存储过程
作者:武汉SEO闵涛  文章来源:敏韬网  点击数1938  更新时间:2009/4/23 18:39:56  文章录入:mintao  责任编辑:mintao
SH=replace(Convert(Char(5),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(5),getdate(),2),''''.'''','''''''')+Replicate(''''0'''',@nL_CDT-1)+''''1''''
                  where MC=@cL_MC
        End
      If  @cL_LX=''''6''''
        begin   -- 前面六位为年月日 ''''000910''''
          Select @nL_CDT=@nL_CD-6
          If  left(@cL_LSH,2)=convert(char(2),getdate(),2) AND Convert(int,substring(@cL_LSH,3,2))=DATEPART(month,getdate())
              AND Convert(Int,SubString(@cL_LSH,5,2))=DatePart(Day,Getdate())
            Begin
              Select @nL_CDM=Len(Rtrim(Convert(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(8),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(8),getdate(),2),''''.'''','''''''')+Replicate(''''0'''',@nL_CDT-1)+''''1''''
                where MC=@cL_MC
        End
    end
  CLOSE LSHB_cursor
  DEALLOCATE LSHB_cursor
  select LSH from LSHB where MC=@cL_MC
End            

GO

上一页  [1] [2] 

打印本文 打印本文 关闭窗口 关闭窗口