I just created this Script to create a Script to delete all User objects in your main database, just test it on the Dev server before executing it on the Production server.
SELECT 'DROP ' + CASE WHEN type = 'U' THEN 'TABLE ' WHEN type = 'P' THEN 'PROCEDURE ' WHEN type = 'FN'THEN 'FUNCTION ' WHEN type = 'V'THEN 'VIEW ' END + Name + CHAR(10) + 'GO' + CHAR(10) FROM Master.sys.objects WHERE is_ms_shipped <> 1 AND TYPE IN ('U','P','FN','V')
Create Script
DROP TABLE Test_table1 GO DROP PROCEDURE usp_Test_Proc1 GO DROP VIEW vw_TestView_1 GO DROP PROCEDURE usp_Test_Proc2 GO DROP FUNCTION udf_Test_Function_GetList GO
Note
If the generated Script tries to delete the table referenced by another table through a foreign key, it throws an error.
M.Ali
source share