1 declare @table varchar(100) 2 declare @i int 3 set @table = 'v3_yqsd_report' 4 set @i=1 5 while @i<=30 6 begin 7 exec('alter database '+@table+' add filegroup OrderGroup'+@i) 8 exec('alter database '+@table+' add file 9 (name=N''order_'+@i+''',filename=N''D:database_v3order_'+@i+'.ndf'',size=5Mb,filegrowth=5mb) 10 to filegroup OrderGroup'+@i) 11 set @i=@i+1 12 end