Solved

sql server 2008: change default file group

Posted on 2011-03-07
1
719 Views
Last Modified: 2012-05-11
I have 2 files with 2 bd group. I no longer wish to use the primary group file, I use this file PFG01 group. Enter the database properties and the site of filegroup, filegroup PFG01 dial by default, but does not work, that is, when I returned to add more records dbFileGroup increased the file that is in the primary group.
 I make that the new information is recorded on the file that is in the group PFG01

CREATE DATABASE dbFileGroup ON  PRIMARY
( NAME = 'dbPart', FILENAME = N'c:\SQLDATA\dbFileGroup.mdf' , SIZE = 3072KB , FILEGROWTH = 100KB )
 LOG ON
( NAME = 'dbPart_log', FILENAME = N'c:\SQLLOG\dbFileGroup_log.ldf' , SIZE = 1024KB , FILEGROWTH = 10%)

go

--
use dbFileGroup
go

CREATE TABLE [dbo].tabla_demo
(  
id int identity primary key,    
c varchar(200) NULL
)

--2
declare @i int
set @i = 1
while @i<=2 -- Luego 1.000.000 filas
begin        
      INSERT INTO dbo.tabla_demo    
      SELECT top (50000)      
               replace(cast(NEWID() as varchar(100)), '-','') + REPLICATE('a', 200-32)    
      FROM AdventureWorks.Sales.SalesOrderHeader  
            CROSS JOIN AdventureWorks.Sales.SalesOrderDetail
      print cast (@i as varchar(100))  
      set @i=@i+1
end

--Creación de los FileGroup
USE master
GO
ALTER DATABASE dbFileGroup ADD FILEGROUP PFG01

--Creación de los DataFile
ALTER DATABASE dbFileGroup ADD FILE
( NAME = N'dbFileGroup1',
  FILENAME = N'C:\SQLDATA\dbFileGroup1.ndf' , SIZE = 3072KB , FILEGROWTH = 512KB )
TO FILEGROUP PFG01

--
use dbFileGroup
go
select MAX(id) from dbo.tabla_demo

declare @i int
set @i = 1
while @i<=1
begin        
      INSERT INTO dbo.tabla_demo    
      SELECT top (50000)      
               replace(cast(NEWID() as varchar(100)), '-','') + REPLICATE('a', 200-32)    
      FROM AdventureWorks.Sales.SalesOrderHeader  
            CROSS JOIN AdventureWorks.Sales.SalesOrderDetail
      print cast (@i as varchar(100))  
      set @i=@i+1
end
0
Comment
Question by:enrique_aeo
1 Comment
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 35058438
setting a default filegroup will ONLY choose which filegroup a NEW table will go to.
new records will still go to the same filegroup(s) the table has been created in.

to move a table from 1 filegroup to another, you have to move it's clustered index to the new filegroup (aka create a [new] clustered index on the new filegroup)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question