东京热无码高清|亚洲区欧洲区综合区视频区|91爱爱电影视频精品激情久久天堂|精品孕妇一区二区三区

首頁(yè) 服務(wù) 產(chǎn)品 文檔 關(guān)于

mssqlserver 刪除包含指定字符串的數(shù)據(jù)表或視圖

刪除表格

CREATE PROCEDURE dbo.PROC_DELTABLE?

AS?
DECLARE @TABLENAME AS NVARCHAR(128)?
DECLARE cur_del CURSOR FOR
select name from sysobjects where type='U' and name like '指定的字符串%'
OPEN cur_del?
FETCH NEXT FROM cur_del INTO @TABLENAME?
WHILE(@@FETCH_STATUS=0)?
BEGIN?
PRINT 'drop table '+@TABLENAME?
EXEC('drop table '+@TABLENAME)?
FETCH NEXT FROM cur_del INTO @TABLENAME?
END?
CLOSE cur_del?
DEALLOCATE cur_del?
GO

EXEC PROC_DELTABLE



刪除視圖

CREATE PROCEDURE dbo.PROC_VIEW
AS?
DECLARE @VIEWNAME AS NVARCHAR(128)?
DECLARE cur_del CURSOR FOR
select name from sysobjects where xtype='v' and name like '指定的字符串%'
OPEN cur_del?
FETCH NEXT FROM cur_del INTO @VIEWNAME?
WHILE(@@FETCH_STATUS=0)?
BEGIN?
PRINT 'drop view '+@VIEWNAME??
EXEC('drop view '+@VIEWNAME?)?
FETCH NEXT FROM cur_del INTO @VIEWNAME?
END?
CLOSE cur_del?
DEALLOCATE cur_del?
GO

EXEC PROC_VIEW