DECLARE @tablename varchar(50) DECLARE @truncatesql varchar(255) DECLARE TrCun_Cursor CURSOR FOR select [name] from sysobjects where type = 'U' --有条件的清空表 name<>'不想清空的表名'-- OPEN TrCun_Cursor FETCH TrCun_Cursor INTO @tablename WHILE(@@fetch_status = 0) BEGIN SET @truncatesql = 'truncate table ' + @tablename --exec(@truncatesql) --当要删除时,就去掉-- PRINT @truncatesql FETCH TrCun_Cursor INTO @tablename END CLOSE TrCun_Cursor DEALLOCATE TrCun_Cursor