June 6, 2012

sp_primary_keys_rowset2 (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_primary_keys_rowset2(nvarchar @table_schema)

MetaData:

   
create procedure sys.sp_primary_keys_rowset2
(
@table_schema sysname = null
)
as
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
-- copy & pasted from version 1 of the SProc and removed checks for 1st parameter !
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
select
TABLE_CATALOG = s_pkv.TABLE_CATALOG,
TABLE_SCHEMA = s_pkv.TABLE_SCHEMA,
TABLE_NAME = s_pkv.TABLE_NAME,
COLUMN_NAME = s_pkv.COLUMN_NAME,
COLUMN_GUID = s_pkv.COLUMN_GUID,
COLUMN_PROPID = s_pkv.COLUMN_PROPID,
ORDINAL = s_pkv.ORDINAL,
PK_NAME = s_pkv.PK_NAME
from
sys.spt_primary_keys_view s_pkv
where
(@table_schema is null or schema_id(@table_schema) = s_pkv.schema_id)
order by 2, 3

No comments:

Post a Comment

Total Pageviews