--select [dbo].[Fn_TimeCard_ToTimeString](685) if exists(select name from sysobjects where name='Fn_TimeCard_ToTimeString') drop function Fn_TimeCard_ToTimeString go create function [dbo].[Fn_TimeCard_ToTimeString](@Num int,@CalcRemind bit) returns varchar(10) as begin declare @res varchar(10)= '', @countZero int=2; if(@Num <= 0) begin return '00:00'; end if(@Num < 60) begin return '00:' + right('00'+cast(@Num as varchar(2)),2); end if(@CalcRemind = 1 and @num >= 1440) begin set @num = @num % 1440; end declare @h int= @num /60; declare @m int= @num % 60; if(@h >= 100 and @h < 1000) begin set @countZero=3; end if(@h >= 1000 and @h < 10000) begin set @countZero=4; end set @res = right('0000'+cast(@h as varchar(5)),@countZero)+':'+right('00'+cast(@m as varchar(2)),2) return @res end go declare @counter int = 0, @formatTime varchar(10)=''; while (@counter <= 2880) begin if(isnull((select ID from OtherProperties where Dom_ID = 689 and Code = @counter),0) = 0) begin set @formatTime = [dbo].[Fn_TimeCard_ToTimeString](@counter,0); insert into OtherProperties(ID,Dom_ID,Code,Value) values((select MAX(ID)+1 from OtherProperties),689,@counter,@formatTime) end SET @counter = @counter+1; end