DECLARE @tablename varchar(50)DECLARE @type varchar(50)DECLARE @truncatesql varchar(255)DECLARE TrCun_Cursor CURSOR FORselect [name],[type] from sysobjects where type = 'U' or type='V'--有条件的清空表 name<>'不想清空的表名'--OPEN TrCun_CursorFETCH TrCun_Cursor INTO @tablename,@typeWHILE(@@fetch_status = 0)BEGIN IF @type='V' SET @truncatesql = 'drop view ' + @tablename exec(@truncatesql) --当要删除时,就去掉-- PRINT @truncatesql IF @type='U' SET @truncatesql = 'drop table ' + @tablename exec(@truncatesql) --当要删除时,就去掉-- PRINT @truncatesql FETCH TrCun_Cursor INTO @tablename,@typeENDCLOSE TrCun_CursorDEALLOCATE TrCun_Cursor