???????????????????????????????????????δ?????????????????????
????????1???????? 12 λ??????? XH+??+6 λ???????????? XH2014000001???? ???? ????????????????????????????
????????????????????????int?????????????????????????????????????????????????????????????????
??????????????????
????Right(str??len)-??η???????len????????????str
????MAX()-????д???
????IsNull() ????????
?????·??
?????????????????庯??
????????XH???
???????YEAR(GETDATE())
??????????и????е???????????6λ?????+1
create function f_GetStudentGuid()
returns varchar(12)
as
begin
declare @studentGuid varchar(12)
select @studentGuid='XH'+CONVERT(varchar??YEAR(GETDATE()))+RIGHT(1000000+ISNULL(RIGHT(MAX(studentGuid)??6)??0)+1??6)
from StudentInfo
return @studentGuid
end
????---------------------
????--?????? ????
????ALTER TABLE studentinfo ADD DEFAULT ([dbo].[f_GetStudentGuid]()) FOR StudentGuid
????GO
????--?????????λ?????????[dbo].[f_GetStudentGuid]()
????????????????????????????????????????е???????????????????????


?????1

?????????????????????????????????????????????
????????1???????? Guid ??? 15 λ??????? CJ+?????? +?????? ??????CJ2013090700001??????????????????????????????????????
?????????????????д???????
????-----------------------------
????------------------------------
create function f_GetScoreGuid()
returns varchar(15)
as
begin
declare @ScoreGuid varchar(15)
declare @time varchar(8)
set @time=CONVERT(varchar??YEAR(GETDATE()))+RIGHT('00'+CONVERT(varchar??month(getdate()))??2)+CONVERT(varchar??DAY(GETDATE()))
select @ScoreGuid='CJ'+@time+RIGHT(100000+ISNULL(RIGHT(MAX(ScoreGuid)??5)??0)+1??5)
from ScoreInfo
return @ScoreGuid
end
??????????????????????λ??
????????·????
????RIGHT('00'+CONVERT(varchar??month(getdate()))??2)
????????


?????2

??????????????????????????????????
????????2??????????? 6 λ??????? YG+4 λ???????????? YG0001??????????????????????????????????????
?????????????????????????????λ?????ɡ?
????????????????????
????????3???????? ID ??? 12 λ??????? GZ+????+4 λ???????????? GZ2015040001????
??????????????????????????????????????
???????
????1 ??????д????
????2 ?? ??ζ????
????3 ???????????
????4 ?????????????????????????????????????????????????????????ɡ?