SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


.mdf question


.mdf question

Author
Message
Nero-1119276
Nero-1119276
SSC-Enthusiastic
SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)

Group: General Forum Members
Points: 109 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
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1499 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
Hall of Fame
Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)

Group: General Forum Members
Points: 3699 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
Roshan Jospeh
Roshan Jospeh
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3149 Visits: 2093
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
SSC-Dedicated
SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)

Group: General Forum Members
Points: 35892 Visits: 11361
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
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3051 Visits: 787
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
SSC-Dedicated
SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)

Group: General Forum Members
Points: 35892 Visits: 11361
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
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3051 Visits: 787
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
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12470 Visits: 9222
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
SSC-Dedicated
SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)

Group: General Forum Members
Points: 35892 Visits: 11361
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