国产精品亚洲综合色拍,人人干人人爱,中文字幕专区在线亚洲,清纯唯美激情视频二区

首頁(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