Create a table on a filegroup other than the default

限于喜欢 提交于 2019-12-04 11:24:42

You can easily check with this sql query:

SELECT o.[name], o.[type], i.[name], i.[index_id], f.[name]
FROM sys.indexes i
INNER JOIN sys.filegroups f
ON i.data_space_id = f.data_space_id
INNER JOIN sys.all_objects o
ON i.[object_id] = o.[object_id]
WHERE i.data_space_id = f.data_space_id
AND o.type = 'U' -- User Created Tables
GO

Just add:

AND f.name = ArchiveFileGroup

to see everything in your new filegroup or:

AND o.name = acr_myTable

to see where your table is located.

If you never added a file to your filegroup, then I would expect an error but you didn't include either an error message or anything saying you did create a file. If you did not, I suggest starting at the microsoft documentation if needed.

The OP found the this helpful trying to create a new file in his filegroup.

You can use sys.filegroups to see all the created file groups in your server like

SELECT *
FROM sys.filegroups

See here for more information List All Objects Created on All Filegroups

It is old post. Want to add information, it might help somebody in future.

sp_help <table_name>

You can see the filegroup, on which the table is created.

NB. You can check by Right-clicking on the table then select properties. on the storage you can see to which the filegroup the new table is belonging

In your case: It will create the table on the default filegroup, not on the new filegroup you created. A filegroup is logical and used to create a secondary file. ex. if you need to create the table on a different location than the default drive, you have to define fileName for the new filegroup.

ALTER DATABASE [db] ADD FILEGROUP [NewFileGroup]

ALTER DATABASE [db] ADD FILE ( NAME = N'NewFile', FILENAME = N':D\..\Newfile.ndf' , SIZE = 8192KB , FILEGROWTH = 65536KB ) TO FILEGROUP [NewFileGroup]

GO

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!