CREATE FUNCTION [NewID]()
RETURNS varchar(20)
AS
BEGIN
DECLARE @_ggmvalue varchar(30)
DECLARE @_ggmvalue1 varchar(30)
DECLARE @_ggmvalue2 varchar(20)
DECLARE @_ggmmilisec varchar(5)
DECLARE @lengthmilisec varchar(5)
DECLARE @_TtmPrefix varchar(16)
DECLARE @_TtmSufix int
DECLARE @_TtmId varchar(22)
DECLARE @length int
select @_ggmvalue1=convert(varchar(10),get_ggm(),112)+convert(varchar(10),get_ggm(),108)
select @_ggmmilisec=convert(varchar(10),_ggmPART(ms,get_ggm()))
set @length=Len(@_ggmmilisec)
if(@length<2)
begin
set @_ggmmilisec='000'+@_ggmmilisec
end
if(@length<3 and @length>=2)
begin
set @_ggmmilisec='00'+@_ggmmilisec
end
if(@length<4 and @length>=3)
begin
set @_ggmmilisec='0'+@_ggmmilisec
end
if(@length>=4)
begin
set @_ggmmilisec=@_ggmmilisec
end
select @_ggmvalue=@_ggmvalue1+@_ggmmilisec
select @_ggmvalue2= Replace(@_ggmvalue,':','')
select @_TtmSufix=Number from randomNumber
select @_TtmPrefix=Substring(@_ggmvalue2,3,18)
set @_TtmId=@_TtmPrefix+convert(varchar(6),@_TtmSufix)
return @_TtmId
END
GO
RETURNS varchar(20)
AS
BEGIN
DECLARE @_ggmvalue varchar(30)
DECLARE @_ggmvalue1 varchar(30)
DECLARE @_ggmvalue2 varchar(20)
DECLARE @_ggmmilisec varchar(5)
DECLARE @lengthmilisec varchar(5)
DECLARE @_TtmPrefix varchar(16)
DECLARE @_TtmSufix int
DECLARE @_TtmId varchar(22)
DECLARE @length int
select @_ggmvalue1=convert(varchar(10),get_ggm(),112)+convert(varchar(10),get_ggm(),108)
select @_ggmmilisec=convert(varchar(10),_ggmPART(ms,get_ggm()))
set @length=Len(@_ggmmilisec)
if(@length<2)
begin
set @_ggmmilisec='000'+@_ggmmilisec
end
if(@length<3 and @length>=2)
begin
set @_ggmmilisec='00'+@_ggmmilisec
end
if(@length<4 and @length>=3)
begin
set @_ggmmilisec='0'+@_ggmmilisec
end
if(@length>=4)
begin
set @_ggmmilisec=@_ggmmilisec
end
select @_ggmvalue=@_ggmvalue1+@_ggmmilisec
select @_ggmvalue2= Replace(@_ggmvalue,':','')
select @_TtmSufix=Number from randomNumber
select @_TtmPrefix=Substring(@_ggmvalue2,3,18)
set @_TtmId=@_TtmPrefix+convert(varchar(6),@_TtmSufix)
return @_TtmId
END
GO
No comments :
Post a Comment