April 27, 2012

sp_helpfile (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_helpfile(nvarchar @filename)

MetaData:

 create procedure sys.sp_helpfile  
@filename sysname = NULL -- file name or all files --
as

set nocount on

if @filename IS NULL
begin
select name, fileid, filename,
filegroup = filegroup_name(groupid),
'size' = convert(nvarchar(15), convert (bigint, size) * 8) + N' KB',
'maxsize' = (case maxsize when -1 then N'Unlimited'
else
convert(nvarchar(15), convert (bigint, maxsize) * 8) + N' KB' end),
'growth' = (case status & 0x100000 when 0x100000 then
convert(nvarchar(15), growth) + N'%'
else
convert(nvarchar(15), convert (bigint, growth) * 8) + N' KB' end),
'usage' = (case status & 0x40 when 0x40 then 'log only' else 'data only' end)
from sysfiles
order by fileid

end
else
begin
if file_id(@filename) IS NULL
begin -- no such file
raiserror (15325, -1, -1, 'file', @filename)
return (1)
end
select name, filename,
filegroup = filegroup_name(groupid),
'size' = convert(nvarchar(15), convert (bigint, size) * 8) + N' KB',
'maxsize' = (case maxsize when -1 then N'Unlimited'
else
convert(nvarchar(15), convert (bigint, maxsize) * 8) + N' KB' end),
'growth' = (case status & 0x100000 when 0x100000 then
convert(nvarchar(3), growth) + N'%'
else
convert(nvarchar(15), convert (bigint, growth) * 8) + N' KB' end),
'usage' = (case status & 0x40 when 0x40 then 'log only' else 'data only' end)
from sysfiles
where fileid = file_id(@filename)
order by fileid
end

return (0) -- sp_helpfile

No comments:

Post a Comment

Total Pageviews