使用SQL脚本删除冗余的视图和表
- SQL脚本删除视图信息
USE Database
GO
IF OBJECT_ID(‘ViewName‘)IS NOT NULL
BEGIN
DROP VIEW ViewName
END
GO - SQL脚本删除表信息
USE Database
GO
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE ID = OBJECT_ID(N‘dbo.TableName‘) AND OBJECTPROPERTY (id,N‘IsUserTable‘) = 1 )
BEGIN
TRUNCATE TABLE TableName
DROP TABLE TableName
END
GO上述脚本仅作参考,如有错误的地方请麻烦指出。
时间: 2024-10-03 21:54:17