Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi
i create a db by following code. now i want to change name of FILEGROUP. how can i do it?
CREATE DATABASE MyDb
ON
PRIMARY ( NAME = MyDat,
FILENAME = 'c:\data\mydat.mdf'),
FILEGROUP MyGroup CONTAINS FILESTREAM( NAME = My,
FILENAME = 'c:\data\my1')
LOG ON ( NAME = MyLog,
FILENAME = 'c:\data\mylog.ldf')
GO

USE MyDb
GO
CREATE TABLE MyTable
(

fId INT IDENTITY PRIMARY KEY,
fData VARBINARY(MAX) FILESTREAM NULL,
fName NVARCHAR(300),
RowGuid UNIQUEIDENTIFIER NOT NULL ROWGUIDCOL UNIQUE DEFAULT NEWID()
)

GO
thanks
Posted

1 solution

Renaming of a filegroup is SQL server can be done as below

SQL
ALTER DATABASE MyDb 
MODIFY FILEGROUP Secondary NAME=MyGroup1

SELECT name FROM sys.filegroups



Important thing to note here is, we can not rename the Primary filegroup as
the name of the primary filegroup cannot be changed.

Rename means move to another group
You cannot move a database file from one filegroup to another filegroup.

instead you can create a new file on the filegroup you want to move the filegroup too and drop/recreate the objects on that filegroup
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900