Happy Monday o/
I’m looking to do the following within a stored proc
select @parameter="fooproc"
drop procedure @parameter
instead of
drop procedure fooproc
But it’s choking with a syntax error. Is there some way I can bend this to my will? I would’ve expected to be able to do this.
I’ve tried a few permutations of type declaration of @parameter to no avail.
Thoughts?
Only with dynamic SQL:
I like to validate object names against database metadata before doing things like this. This protects against errors up front and even injection in the later dynamic section.
i.e. something like: