Monday, 20 July 2015

TSQL: SP_HELP

SP_HELP
  • System stored procedure that returns object metadata
  • Requires "public" role membership and at least one permission granted to the table
Syntax:
sp_help [<tablename>]

Example:
sp_help article

For tables, it returns:
  • Table details - owner, date created
  • Columns and their data types, nullability, collation, if they're computed columns
  • Identity columns, seed and increment values
  • RowGUIDCol information
  • Filegroup where the data is located
  • Index names and keys
  • Constraint types, actions for delete and update, replication status
  • Tables referencing by foreign key
sp_help (without the object name) returns the following:
  • List of all views, user tables, constraints, synonyms, functions, queues, defaults,  and system objects within the database
  • List of user types within the database

No comments:

Post a Comment