EDIT: the function creation was missing, sorry about that
I have a T-SQL request that goes:
DECLARE @IsSomething bit
SET @IsSomething = 0
IF /some tests/ SET @IsSomething = 1
EXEC('
CREATE FUNCTION IsSomething ()
RETURNS bit
AS
BEGIN
RETURN ' + @IsSomething + '
END')
Of course if I run it twice I get
There is already an object named 'IsSomething ' in the database.
How would I do something like this:
IF EXIST @IsSomething DESTROY @IsSomething // (Pseudo bad code)
Thanks!