Obliterate Database

declare @vcFK varchar(250), @vcTable varchar(250), @vcSP varchar(250), @vcView varchar(250), @vcFn varchar(250) — …drop all foreign key constraints select @vcFK = min(name) from sysobjects where type=’F’ while @vcFK is not null begin print ‘Dropping FK constraint […]

SQL Tricks

Delete all tables EXEC sp_MSforeachtable @command1 = “DROP TABLE ?”  Grant execute permissions to all stored procedures to a specific user CREATE PROC grantexecutepermission( @UserName NVARCHAR(250)) AS DECLARE curse CURSOR  FOR SELECT name FROM   sysobjects WHERE  TYPE = ‘P’ OPEN curse DECLARE  @proc VARCHAR(100) DECLARE  […]