?
Solved

sql server 2008: change default file group

Posted on 2011-03-07
1
Medium Priority
?
748 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

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 …
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

762 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