• Here's an option using an inline table-valued function which would perform a lot better than a normal function. It also has a test to show how does it work.

    The code is simple, but you should examine it piece by piece to understand what it is doing.

    USE Test

    GO

    CREATE FUNCTION TimeCharFromInt(

    @Time int

    )RETURNS TABLE WITH SCHEMABINDING

    AS

    RETURN

    SELECT CASE WHEN @Time > 0

    THEN STUFF( SUBSTRING( CONVERT(varchar(26), DATEADD(ss, @Time, 0), 109), 13, 16), 6, 7, '')

    ELSE '' END TimeChar;

    GO

    SELECT number * 60, t.TimeChar

    FROM master.dbo.spt_values

    CROSS APPLY dbo.TimeCharFromInt( number*60) t

    WHERE type = 'P'

    GO

    DROP FUNCTION TimeCharFromInt

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2