I need a function within a script. At any time when this script is run, the function may or may not exist. I have tried writing it in the form of
IF EXISTS
CREATE FUNCTION
GO
This gives an error saying the function already exists (I guess because they are in separate statements)
I have also tried
IF NOT EXISTS
This gives me an error that says the create function must be the only item in the statement.
Is there any way to check for the existence of the function and delete it followed by a CREATE FUNCTION statement that will run if the function already exists or create the function within a IF NOT EXISTS statement?
IF EXISTS
DROP FUNCTION
GOCREATE FUNCTION
GO
This gives an error saying the function already exists (I guess because they are in separate statements)
I have also tried
IF NOT EXISTS
CREATE FUNCTION
GOThis gives me an error that says the create function must be the only item in the statement.
Is there any way to check for the existence of the function and delete it followed by a CREATE FUNCTION statement that will run if the function already exists or create the function within a IF NOT EXISTS statement?