Friday, 17 May 2013
Drop All Tables in SQL Server Database and store procedure
Following script delete all table from databse except with Foreighn Key table
select name into #tables from sys.objects where type = 'U'
while (select count(1) from #tables) > 0
begin
declare @sql varchar(max)
declare @tbl varchar(255)
select top 1 @tbl = name from #tables
set @sql = 'drop proc ' + @tbl
exec(@sql)
delete from #tables where name = @tbl
end
drop proc #tables;
To Drop All Store Procedure :
select name into #tables from sys.objects where type = 'p'
while (select count(1) from #tables) > 0
begin
declare @sql varchar(max)
declare @tbl varchar(255)
select top 1 @tbl = name from #tables
set @sql = 'drop proc ' + @tbl
exec(@sql)
delete from #tables where name = @tbl
end
drop proc #tables;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment