DECLARE @name VARCHAR(50)
DECLARE table_cursor CURSOR FOR
SELECT name FROM sys.tables
OPEN table_cursor
FETCH NEXT FROM table_cursor INTO @name;
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT 'TRUNCATE TABLE ' + @name;
EXEC ('TRUNCATE TABLE ' + @name);
FETCH NEXT FROM table_cursor INTO @name;
END
CLOSE table_cursor;
DEALLOCATE table_cursor;
沒有留言:
張貼留言