Skip to content

Instantly share code, notes, and snippets.

View SergVro's full-sized avatar

Sergii Vorushylo SergVro

  • Stockholm, Sweden
View GitHub Profile
@SergVro
SergVro / ResetDB.sql
Created August 1, 2017 19:48
Removes all objects from a SQL database
/* Drop all non-system stored procs */
DECLARE @name VARCHAR(128)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'P' AND category = 0 ORDER BY [name])
WHILE @name is not null
BEGIN
SELECT @SQL = 'DROP PROCEDURE [dbo].[' + RTRIM(@name) +']'
EXEC (@SQL)