'Delete ALL Assemblies from SQL Server
Question is pretty simple but just in case I'll explain it.
Is there a way to drop ALL the the assemblies in a Microsoft SQL Server?
I know that there's a way to delete them on at a time using
DROP ASSEMBLY ['assembly_name'];
Solution 1:[1]
Note: this code does not allow for dependencies between assemblies, so you may have to run it 2-3 times before all assemblies are dropped.
/* Drop all assemblies */
DECLARE @SQL VARCHAR(MAX)
DECLARE @name VARCHAR(128)
DECLARE cur CURSOR FAST_FORWARD READ_ONLY FOR
SELECT name FROM sys.assemblies WHERE is_user_defined=1
OPEN cur
FETCH NEXT FROM cur INTO @name
WHILE @@FETCH_STATUS = 0
BEGIN
SELECT @SQL = 'DROP ASSEMBLY ' + RTRIM(@name)
PRINT @SQL
EXEC (@SQL)
FETCH NEXT FROM cur INTO @name
END
CLOSE cur
DEALLOCATE cur
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
