• Some people do something like this:

    --If object doesn't exist, create a dummy object

    IF OBJECT_ID('dbo.InexistentFunction') IS NULL

    EXEC('CREATE FUNCTION InexistentFunction()

    RETURNS int

    AS

    BEGIN

    RETURN 0

    END')

    GO

    --Simply alter the object to get the correct definition.

    ALTER FUNCTION dbo.InexistentFunction

    (

    @MyParam int

    )

    RETURNS date

    AS

    BEGIN

    RETURN DATEADD( dd, @MyParam, GETDATE())

    END

    GO

    --Test

    SELECT dbo.InexistentFunction(10)

    --Cleanup (just for this example)

    DROP FUNCTION InexistentFunction

    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