首页 > 代码库 > sql server 删除表及表的相关视图、存储过程、方法

sql server 删除表及表的相关视图、存储过程、方法

注意:进行此操作前需先备份数据库,免得删错无法恢复

1.查询

SELECT
 Name
,type 
FROM SysObjects 
WHERE name LIKE %cases% 

2.拼接语句

SELECT
drop Procedure +
 Name
FROM SysObjects 
WHERE name LIKE %cases% 
AND type=p;


SELECT
drop view +
 Name
FROM SysObjects 
WHERE name LIKE %cases% 
AND type=v;



SELECT
drop table +
 Name
FROM SysObjects 
WHERE name LIKE %cases% 
AND type=u;



SELECT
drop function +
 Name
FROM SysObjects 
WHERE name LIKE %cases% 
AND type=fn

 3.执行删除语句

sql server 删除表及表的相关视图、存储过程、方法