USE [DBNAME]
GO
DECLARE @tablename AS VARCHAR (1000)
DECLARE @sql AS VARCHAR (1000)
IF OBJECT_ID('tempdb.dbo.#tables') IS NOT NULL
DROP TABLE #tables
SELECT *
INTO #tables
FROM sys.tables
WHILE EXISTS (SELECT * FROM #tables)
BEGIN
SELECT @tablename = name
FROM #tables
SELECT @sql = 'truncate table ' + @tablename;
PRINT @sql
EXECUTE (@sql)
DELETE #tables
WHERE name = @tablename;
END
No comments:
Post a Comment