⽅法⼀、
--删除单个视图
DROP VIEW view_name
--删除多个视图
DROP VIEW view_name1,view_name2
declare @table varchar(600)
while (select count(*) from sysobjects where type='u')>=1
begin
set @table=(select top 1 name from sysobjects where type='u')
set @table='drop table
exec(@table)
end
select name,type from sysobjects where type='u'
while (select count(*) from sysobjects where type='v')>=1
begin
set @table=(select top 1 name from sysobjects where type='v')
set @table='drop view
exec(@table)
end
select name,type from sysobjects where type='v'
DECLARE @STRING VARCHAR(8000)
WHILE EXISTS(SELECT NAME FROM SYSOBJECTS WHERE TYPE='P' AND STATUS>=0 and uid=1)
BEGIN
SELECT TOP 1 @STRING='DROP PROCEDURE '+NAME FROM SYSOBJECTS WHERE TYPE = 'P' AND STATUS>=0 and uid=1 --SELECT @STRING
EXEC(@STRING)记住我
END
发布评论