Solved

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

Posted on 2011-02-16
5
431 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

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

636 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