tempdb多文件处理

DECLARE @sql VARCHAR(max)
DECLARE @name VARCHAR(max)
DECLARE @path VARCHAR(max)
DECLARE @i VARCHAR(max)

SET @i=1
WHILE (@i<=48)
BEGIN

SET @name='tempdev'+CAST(@i AS VARCHAR(20))
SET @path='F:\tempdb\'+@name+'.ldf'
SET @sql='
USE [master]
ALTER DATABASE [tempdb]
ADD FILE ( NAME = N
'''+@name+''',
FILENAME = N
'''+@path+''' ,
SIZE = 3072KB ,
MAXSIZE = 512000KB ,
FILEGROWTH = 102400KB
)
'
EXEC( @sql)
set @i=@i+1
END
posted @ 2011-07-26 21:34  qanholas  阅读(288)  评论(0编辑  收藏  举报