DECLARE p CURSOR for
SELECT name FROM sys.tables t
WHERE t.[type] = 'U' AND CHARINDEX('SYS',t.name) =0
ORDER BY t.name
OPEN p
DECLARE @tablename VARCHAR(50)
DECLARE @sql VARCHAR(max)
SET @sql= ''
FETCH NEXT FROM p INTO @tablename
WHILE @@FETCH_STATUS =0
BEGIN
PRINT 'TRUNCATE TABLE ' + @tablename
FETCH NEXT FROM p INTO @tablename
END
CLOSE p
DEALLOCATE p
上一篇: SqlServer的limit实现-ROW_NUMBER()
下一篇: SqlServer日期操作