Tuesday, March 27, 2012

Data File and Filegroup in DB Properties

Hi All,
Is it possible to change db file to single file from multiple files?
Thanks any help
MelihMelih wrote:
> Hi All,
> Is it possible to change db file to single file from multiple files?
> Thanks any help
> Melih
Look up DBCC SHRINKFILE, particularly the EMPTYFILE clause.|||Melih,
Sure, you can remove a file from a filegroup when it is empty, using "alter
database". To empty the file use "DBCC SHRINKFILE(file_name | fiel_id,
EMPTYFILE)", it move the data to others files in the filegroup and mark it so
no more data is added to it.
Example:
use northwind
go
alter database northwind
add file (name=northwind_2,filename='c:\temp\northwind_data_2.ndf',size=512KB)
go
-- not needed in this case because it is empty
dbcc shrinkfile(northwind_2, EMPTYFILE)
go
alter database northwind
remove file northwind_2
go
AMB
"Melih" wrote:
> Hi All,
> Is it possible to change db file to single file from multiple files?
> Thanks any help
> Melih

No comments:

Post a Comment