April 27, 2012

sp_helpfilegroup (Transact-SQL MetaData) Definition

Please note: that the following source code is provided and copyrighted by Microsoft and is for educational purpose only.
The meta data is from an SQL 2012 Server.

I have posted alot more, find the whole list here.

Goto Definition or MetaData

Definition:

sys.sp_helpfilegroup(nvarchar @filegroupname)

MetaData:

 create procedure sys.sp_helpfilegroup  
@filegroupname sysname = NULL -- filegroup name or all filegroups --
as

set nocount on
-- status & 0x40 is a log file and thus not in any filegroup
if @filegroupname IS NULL
begin
select g.groupname, g.groupid, 'filecount' =
(select count(*) from sysfiles f
where f.groupid = g.groupid
and (f.status & 0x40 <> 0x40))
from sysfilegroups g
end
else
begin
if (filegroup_id(@filegroupname) IS NULL)
begin
raiserror (15325, -1, -1, 'filegroup', @filegroupname)
return (1)
end
select g.groupname, g.groupid, 'filecount' =
(select count(*) from sysfiles f
where f.groupid = g.groupid
and (f.status & 0x40 <> 0x40))
from sysfilegroups g
where g.groupid = filegroup_id(@filegroupname)

select 'file_in_group' = name, fileid, filename,
'size' = convert(nvarchar(15), size * 8) + N' KB',
'maxsize' = (case maxsize when -1 then N'Unlimited'
else
convert(nvarchar(15), maxsize * 8) + N' KB' end),
'growth' = (case status & 0x100000 when 0x100000 then
convert(nvarchar(3), growth) + N'%'
else
convert(nvarchar(15), growth * 8) + N' KB' end)
from sysfiles
where groupid = filegroup_id(@filegroupname)
and (status & 0x40 <> 0x40)
order by fileid
end

return (0) -- sp_helpfilegroup

No comments:

Post a Comment

Total Pageviews