Solved

Moving the 49 GB of tbl from one drive to another drive

Posted on 2011-02-16
5
426 Views
Last Modified: 2012-05-11
We have to move one table of 49 GB which I need to move  to another drive as the data file in the drive is consuming the space. The Primary datafile is about 500 GB. All the tables in the data file is partitioned according to partition schema based on the datekey. Can I move each table from one drive (H) to other drive  i.e to E drive from the primary file group to different/ secondary file group by creating different file groups.

Do we get any issues/problems if I move the table to another file group and simulataneously changing the location of the drive? Is it possible. But I tested in the Test env for smaller tables but I donno for the table of that size will it work or not because we gonna do it in PROD so anything goes wrong I'll be in danger.

Create a new file group with the secondary file group

ALTER DATABASE MC
ADD FILEGROUP [SAPROWCOUNT]

--Specify the location for the filegroup

ALTER DATABASE MC
ADD FILE
( NAME = SAPROWCount,
FILENAME = 'E:\ SAPROWCount_Secondary.ndf',
SIZE = 500 MB,         --- depends on the requirement
MAXSIZE = Unlimited,---depends on the requirement
FILEGROWTH = 10%)     ---depends on the requirement
TO FILEGROUP [SAPROWCOUNT]
GO

--Drop the constraint on the count table

ALTER TABLE [SAPROWCount]
DROP CONSTRAINT [SAPROWCount] WITH (MOVE TO SAPROWCOUNT)




--Adding the constraint to the primary clustered key to the table

ALTER TABLE [SAPROWCount]
ADD CONSTRAINT [PKSAPROWCount] PRIMARY KEY CLUSTERED
(   UserAgentKey ASC,
     PageUrlKey ASC,
       InternalSource ASC,
       DateKey ASC,
       EventDateKey  ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [SAPROWCOUNT]

--Adding the constraints to the table

ALTER TABLE [dbo].[SAPROWCount]  WITH CHECK ADD  CONSTRAINT [FKSAPROWCountPageUrl] FOREIGN KEY([PageUrlKey])
REFERENCES [dbo].[DimPageUrl] ([PageUrlKey])
GO


ALTER TABLE [dbo].[FACTSAPROWCount]
CHECK CONSTRAINT [FKFACT SAPROWCountUserAgent]
GO

COUld you please verify if this script wrks fine or any suggestions would help me

Waiting for your reply.

Thanks,
0
Comment
Question by:srionline2k6
[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
5 Comments
 
LVL 16

Expert Comment

by:EvilPostIt
ID: 34914176
Sounds like the same process which sprang to mind for me. Test it with another database on a test machine to ensure the code will work.
0
 
LVL 20

Expert Comment

by:Marten Rune
ID: 34958219
Can I move each table from one drive (H) to other drive  i.e to E drive from the primary file group to different/ secondary file group by creating different file groups.
ANSWER: YES

Do we get any issues/problems if I move the table to another file group and simulataneously changing the location of the drive?
ANSWER: No issues I know of

This is a standard database design, nothing out of the ordinary, except for the size of the table. I would make sure backup exist before. Test their integrity with restore verify only on a second system and your'e ready to go. Make sure you have a maintenancewindow big enough.

//Marten
0
 
LVL 38

Accepted Solution

by:
Jim P. earned 125 total points
ID: 34976613
I would change this
ADD FILE
( NAME = SAPROWCount,
FILENAME = 'E:\ SAPROWCount_Secondary.ndf',
SIZE = 500 MB,         --- depends on the requirement
MAXSIZE = Unlimited,---depends on the requirement
FILEGROWTH = 10%)     ---depends on the requirement
TO FILEGROUP [SAPROWCOUNT]

Open in new window

to this:
ADD FILE
( NAME = SAPROWCount,
FILENAME = 'E:\ SAPROWCount_Secondary.ndf',
SIZE = 40GB,         --- depends on the requirement
MAXSIZE = Unlimited,---depends on the requirement
FILEGROWTH = 2GB)     ---depends on the requirement
TO FILEGROUP [SAPROWCOUNT]

Open in new window


Percent of file growth is a bad idea. Especially when you have a database that can take data loads.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

733 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