I love to organize my SQL Server database objects using schemas and in my current project I need to create a lot of them dynamically so I also need to manage a way to delete them :).
So I implemented a stored procedure that allows me to delete the schema and all it related objects in a database (also specified by parameter).
exec dbo.DropSchema @schemaName = ‘schema’, @database = ‘[Database]’, @whatif = 1
You can download the procedure script here.
If you find any bugs or have any sugestion please fell free to comment.
- SYS.OBJECTS specification
- A valuable post from Ranjith Kumar where I got some of the code to find the schema related objects