Solved

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

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sql server insert 12 30
MS SQL BCP Extra Lines Between Records 2 15
SSRS Enable Remote Errors 4 23
performance query 4 20
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…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
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 SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

785 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