SQL Server 如果视图存在执行删除
IF EXISTS(Select Name From Sysobjects Where Name='P_ExistsDropView' And Xtype='P') DROP PROC P_ExistsDropView GO Create Proc P_ExistsDropView ( @DelView Varchar(200) ) As Declare @SQLText Varchar(1000) If Exists(Select Top 1 Name From Sysobjects Where Name=@DelView And XType='V') Begin Set @SQLText='Drop View ' + @DelView Exec(@SQLText) End
调用方式:
Exec P_ExistsDropView 'View'
记录Coding学习过程中的点点滴滴,记性不好,特别需要这么一个博客 逸'Coding'Blog