?
Solved

sql server 2008: change default file group

Posted on 2011-03-07
1
Medium Priority
?
761 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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

850 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