Tuesday, 12 April 2016

How to get the definition of objects in SQL server ?

 Following options are used to get the definition of objects in SQL server.

TABLE:
SYNTAX:
SP_HELP [TABLE NAME]

EXAMPLE:
SP_HELP StudentDetail


In above example we can find some of the table details in Results tab.

Name --> Refers to table Name
Created Date--> Refers to table created date
Column Name --> Refers the column names in table
Type --> Refers to Data type
Computed --> Refers to the computed column
Length --> Refers the Column length
Nullable --> Refers to nullable column or not
Collation --> Refers to the column collation
Identity --> Refers to the identity column
RowGuidCol --> Refers to the RowGuidCol column
Index Name --> Refers to the Index Name for the index column
Index key --> Refers to the index column name
Constraint type --> Refers to the constraint type such as primary key constraint ,foreign key constraint,default constraint etc.


Database Objects:
SYNTAX:
SP_HELPTEXT [Database Objects]

EXAMPLE:
SP_HELPTEXT pGetStudentDetail

Database objects such as stored procedures ,functions ,triggers and views.
For all objects (except tables) we can use the above syntax to get the definition.

No comments:

Post a Comment