SQL Server: Dropping objects from 2000, 2005, 2008

From 2000

--Drop All Constraints
select + 'alter table ' + table_schema + '.'+ table_name + ' drop constraint '+ constraint_name  from INFORMATION_SCHEMA.TABLE_CONSTRAINTS
where table_name in (
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
where table_name like 'tbl%'  );
 
                                --Drop All Views
Select 'drop view '+ name From sysobjects
Where type = 'V' and name like '%vw%';
 
--Drop All Tables
select + 'drop table ' + table_schema + '.'+ table_name
from INFORMATION_SCHEMA.TABLES
where table_name like 'tbl%';
 
 http://www.daniweb.com/web-development/databases/ms-sql/threads/51556/get-table-list-from-sql-2k-server
http://sujithcjose.blogspot.com.au/2009/01/list-all-stored-procedurestables-or.html

Comments

Popular posts from this blog

SQL Server: Finding Query using SPID

Restoring Master, Model and MSDB from Netbackup