April 25, 2012

sp_help_fulltext_columns (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_help_fulltext_columns(nvarchar @table_name
, nvarchar @column_name)

MetaData:

 create procedure sys.sp_help_fulltext_columns  
@table_name nvarchar(517) = NULL, -- table name
@column_name sysname = NULL -- column name
as
-- FULLTEXT MUST BE ACTIVE IN DATABASE --
if DatabasePropertyEx(db_name(), 'IsFulltextEnabled') = 0
begin
raiserror(15601,-1,-1)
return 1
end

if @table_name is not null
begin
-- VALIDATE TABLE NAME --
-- (1) Must exist in current database
declare @objid int
select @objid = object_id(@table_name, 'local')
if @objid is null
begin
declare @curdbname sysname
select @curdbname = db_name()
raiserror(15009,-1,-1 ,@table_name, @curdbname)
return 1
end
-- (2) Must be a user table or indexed view (and not a temp table)
if (ObjectProperty(@objid, 'IsUserTable') = 0 AND (ObjectProperty(@objid, 'IsView') = 0 OR ObjectProperty(@objid, 'IsIndexed') = 0 )) OR
substring(parsename(@table_name,1),1,1) = '#'
begin
raiserror(15218,-1,-1 ,@table_name)
return 1
end

-- VALIDATE COLUMN NAME --
if @column_name is not null
begin
declare @typename sysname
select @typename = type_name(ColumnProperty(@objid, @column_name, 'SystemType'))
if @typename is null
begin
raiserror(15104,-1,-1,@table_name,@column_name)
return 1
end
end

end

-- We are using schema owner as table owner now. Check with garish for their decision on using schema owner
-- in place of table owner for backward compatibility issue.
select distinct
ssche.name as TABLE_OWNER,
sftcol.object_id as TABLE_ID,
sobj.name as TABLE_NAME,
scol.name as FULLTEXT_COLUMN_NAME,
sftcol.column_id as FULLTEXT_COLID,
scol2.name as FULLTEXT_BLOBTP_COLNAME,
case sftcol.type_column_id
when 0 then null
else sftcol.type_column_id
end as FULLTEXT_BLOBTP_COLID,
sftcol.language_id as FULLTEXT_LANGUAGE
from
sys.fulltext_index_columns as sftcol
-- the nolock is to not block while crawl or master merge is creating fragments
join sys.objects as sobj WITH (NOLOCK) on(sftcol.object_id = sobj.object_id)
join sys.columns as scol on (sftcol.object_id = scol.object_id and sftcol.column_id = scol.column_id)
left outer join sys.columns as scol2 on (sftcol.object_id = scol2.object_id and sftcol.type_column_id = scol2.column_id)
join sys.schemas as ssche on (sobj.schema_id = ssche.schema_id)
where (
@column_name is null or
scol.name = @column_name
)
AND (
@table_name is null or
sobj.object_id = @objid
)
order by TABLE_OWNER, TABLE_NAME, FULLTEXT_COLID

-- SUCCESS --
return 0 -- sp_help_fulltext_columns

No comments:

Post a Comment

Total Pageviews