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