CREATE FUNCTION fnNextSortOrder(@Seed datetime = '1/1/2001')
RETURNS bigint
AS BEGIN
DECLARE @Val bigint
SET @Val = (year(@Seed)*10000000000) +
(month(@Seed)*100000000) +
(day(@Seed)*1000000)+
(datepart("hh",@Seed)*10000)+
(datepart("mm",@Seed)*100)+
(datepart("ss",@Seed))*100
RETURN @Val
END
GO
|