SQL删除所有表数据
use xxx -- 数据库名
DECLARE tables_cursor CURSOR
FOR
SELECT name FROM sysobjects WHERE type = \'U\'
OPEN tables_cursor
DECLARE @tablename sysname
FETCH NEXT FROM tables_cursor INTO @tablename
WHILE (@@FETCH_STATUS <> -1)
BEGIN
EXEC (\'TRUNCATE TABLE \' + @tablename)
FETCH NEXT FROM tables_cursor INTO @tablename
END
DEALLOCATE tables_cursor