日期:2014-05-17 浏览次数:20602 次
DECLARE @tbname VARCHAR(50);
DECLARE cur CURSOR FOR SELECT name FROM sys.sysobjects;
OPEN cur;
FETCH NEXT FROM cur INTO @tbname;
WHILE @@FETCH_STATUS=0
BEGIN
TRUNCATE TABLE @tbname;
FETCH NEXT FROM cur INTO @tbname;
END;
CLOSE cur;
DEALLOCATE cur;
select * from sys.tables
DECLARE @tbname VARCHAR(50);
DECLARE cur CURSOR FOR SELECT name FROM sys.tables;
OPEN cur;
FETCH NEXT FROM cur INTO @tbname;
WHILE @@FETCH_STATUS=0
BEGIN
exec('TRUNCATE TABLE '+@tbname);
FETCH NEXT FROM cur INTO @tbname;
END;
CLOSE cur;
DEALLOCATE cur;