April 30, 2012

sp_indexes (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_indexes(nvarchar @table_server
, nvarchar @table_name
, nvarchar @table_schema
, nvarchar @table_catalog
, nvarchar @index_name
, bit @is_unique)

MetaData:

   
create procedure sys.sp_indexes
(
@table_server sysname,
@table_name sysname = null,
@table_schema sysname = null,
@table_catalog sysname = null,
@index_name sysname = null,
@is_unique bit = null
)
as
select
TABLE_CAT = TABLE_CATALOG,
TABLE_SCHEM = TABLE_SCHEMA,
TABLE_NAME = TABLE_NAME,
NON_UNIQUE = convert(smallint, 1 - [UNIQUE]),
INDEX_QUALIFIER = TABLE_NAME,
INDEX_NAME = INDEX_NAME,
TYPE = case [CLUSTERED]
when 1 then 1
else 3
end,
ORDINAL_POSITION = ORDINAL_POSITION,
COLUMN_NAME = COLUMN_NAME,
ASC_OR_DESC = case [COLLATION]
when 1 then 'A'
when 2 then 'D'
else null
end,
CARDINALITY = CARDINALITY,
PAGES = case [CLUSTERED]
when 1 then PAGES
else NULL
end,
FILTER_CONDITION = FILTER_CONDITION

from
sys.fn_remote_indexes (
@table_server,
@table_catalog,
@table_schema,
@index_name,
NULL, -- TYPE (index type)
@table_name)
where
@is_unique is null or @is_unique = [UNIQUE]
order by NON_UNIQUE, TYPE, INDEX_QUALIFIER, INDEX_NAME, ORDINAL_POSITION

No comments:

Post a Comment

Total Pageviews