使用游标删除库的所有表
DECLARE @tablename varchar(20) DECLARE CUR CURSOR FOR SELECT name FROM sysobjects WHERE type = 'U' OPEN CUR FETCH NEXT FROM CUR INTO @tablename WHILE @@FETCH_STATUS=0 BEGIN EXEC ('TRUNCATE TABLE ' + @tablename) FETCH NEXT FROM CUR INTO @tablename END CLOSE CUR; DEALLOCATE CUR;