June 6, 2012

sp_primarykeys (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_primarykeys(nvarchar @table_server
, nvarchar @table_name
, nvarchar @table_schema
, nvarchar @table_catalog)

MetaData:

   
create procedure sys.sp_primarykeys
(
@table_server sysname,
@table_name sysname = null,
@table_schema sysname = null,
@table_catalog sysname = null
)
as
select
TABLE_CAT = TABLE_CATALOG,
TABLE_SCHEM = TABLE_SCHEMA,
TABLE_NAME = TABLE_NAME,
COLUMN_NAME = COLUMN_NAME,
KEY_SEQ = ORDINAL,
PK_NAME = convert(sysname, NULL)

from
sys.fn_remote_primary_keys (
@table_server,
@table_catalog,
@table_schema,
@table_name)
order by TABLE_CAT, TABLE_SCHEM, TABLE_NAME, KEY_SEQ

No comments:

Post a Comment

Total Pageviews