I want to drop all the functions in a schema, and I don't want to write something that requires me to get all the function names ahead of time and write it in the SQL
DROP FUNCTION MySchema.FunctionName1
DROP FUNCTION MySchema.FunctionName2
... etc
I tried:
DECLARE @FuncName varchar(100)
WHILE (SELECT Count(*) From information_schema.routines
WHERE SPECIFIC_SCHEMA = 'MySchema' AND ROUTINE_TYPE = 'function') > 0
BEGIN
SELECT top(1) @FuncName = ROUTINE_NAME FROM information_schema.routines
WHERE SPECIFIC_SCHEMA = 'MySchema' AND ROUTINE_TYPE = 'function'
BEGIN
DROP FUNCTION @FuncName -- it doesn't like it because it is a string variable
END
END
sql script to drop old versions of stored procedures and functions is kinda similar but just generates SQL like the first example and doesn't actually run it