Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


.mdf question


.mdf question

Author
Message
Nero-1119276
Nero-1119276
SSC Rookie
SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)

Group: General Forum Members
Points: 39 Visits: 132
hi all,
In my database i want to create new *.mdf file and i want to transfer selected tables frmo old mdf to new one.Is this possible?

If yes how to create and how to move data from old mdf to new mdf?


Thanks,
Neerav
hi_abhay78
hi_abhay78
SSC Veteran
SSC Veteran (267 reputation)SSC Veteran (267 reputation)SSC Veteran (267 reputation)SSC Veteran (267 reputation)SSC Veteran (267 reputation)SSC Veteran (267 reputation)SSC Veteran (267 reputation)SSC Veteran (267 reputation)

Group: General Forum Members
Points: 267 Visits: 386
create a new database and import the tables form the old database .

Abhay Chaudhary
Sr.DBA (MCITP/MCTS :SQL Server 2005/2008 ,OCP 9i)
Schadenfreude-Mei
Schadenfreude-Mei
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1129 Visits: 1336
neerav.saini (6/24/2009)
hi all,
In my database i want to create new *.mdf file and i want to transfer selected tables frmo old mdf to new one.Is this possible?

If yes how to create and how to move data from old mdf to new mdf?


Thanks,
Neerav


If i understand you, think you are talking about adding aditional datafiles (segment/partitions). This can be done and relatively eaasily. Why do you want to do this though?

Or have i misunderstood. Either way look at BOL under 'Data partition'. :-)

Adam Zacks

-------------------------------------------

Be Nice, Or Leave
joeroshan
joeroshan
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1045 Visits: 1987
You can add data file using alter database
ALTER DATABASE Database_name ADD FILE
(NAME='Logical_name',
FILENAME='Physical_name')



You can move data using
DBCC SHRINKFILE('logical_name','EMPTYFILE')



But I dont know wether it works completely for primary filegroup with system meta data

If you want to move the the file why dont you detach move and attach?

----------------------------------------------------------------------------------------------------------------------------------------------------
Roshan Joe


Jeff Moden -Forum Etiquette: How to post data/code on a forum to get the best help
Paul White
Paul White
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10338 Visits: 11350
My guess (FWIW) is that the question is about moving a table to a secondary filegroup (typically named *.NDF)

If so, the following MSDN article explains files and filegroups and links to the SQL DDL statements required:

http://msdn.microsoft.com/en-us/library/ms189563(SQL.90).aspx



Paul White
SQLPerformance.com
SQLblog.com
@SQL_Kiwi
MannySingh
MannySingh
SSChasing Mays
SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)

Group: General Forum Members
Points: 649 Visits: 775
so you want to create a secondary Datafile (.ndf) and create new table(s) to ndf.
that is easy. But it would a good practise to add a filegroup and then add the ndf to the new filegroup.. this will help in database maintenance tasks, as backup just the primary filegroup etc... but it depends in your scenario: and the most important part is SQL Server will never know to place any new objects on the secondary file, but you can create the object with the ON clause in the new Filegroup... correct me if i am wrong.

and regarding moving the Table.. you cannot as per my understanding, you can only specify create table with on clause to create it in the new filegroup.

Alter Database DBNAME
ADD FILE
(
NAME = NewFileName,
FILENAME = 'PathToFile.ndf',
SIZE = xxx,
FILEGROWTH = xxx
)

Maninder
www.dbanation.com
Paul White
Paul White
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10338 Visits: 11350
Mani,

You can move a table from one file-group to another by rebuilding the clustered index with the ON clause.
Non-clustered indexes work the same way but would have to be done separately.

Paul



Paul White
SQLPerformance.com
SQLblog.com
@SQL_Kiwi
MannySingh
MannySingh
SSChasing Mays
SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)

Group: General Forum Members
Points: 649 Visits: 775
paul is correct, i completely forgot about that.. i should stop thinking about my girlfriends all the time. :-D

Maninder
www.dbanation.com
homebrew01
homebrew01
SSCrazy
SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)

Group: General Forum Members
Points: 2976 Visits: 9071
Mani Singh (6/24/2009)
paul is correct, i completely forgot about that.. i should stop thinking about my girlfriends all the time. :-D


How many do you have ? (To have such problems)



Paul White
Paul White
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10338 Visits: 11350
homebrew01 (6/24/2009)
Mani Singh (6/24/2009)
paul is correct, i completely forgot about that.. i should stop thinking about my girlfriends all the time. :-D

How many do you have ? (To have such problems)

I really hope we don't go too far down this particular track Doze



Paul White
SQLPerformance.com
SQLblog.com
@SQL_Kiwi
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search