Using ‘SysObjects’ we can get the list of objects in a particular database.
EXAMPLE:
1. It will return the number of rows with other columns for objects present in a database.
SELECT * FROM sysobjects
2. It will return the number of rows with other columns for a particular object in a database.
SELECT * FROM sysobjects where xtype=’n’
Where n is xtype values.
Following are the possible values of xtype
Value
|
Object
|
C
|
CHECK constraint
|
D
|
Default or DEFAULT constraint
|
F
|
FOREIGN KEY constraint
|
L
|
Log
|
P
|
Stored procedure
|
PK
|
PRIMARY KEY constraint
|
RF
|
Replication filter stored procedure
|
S
|
System table
|
TR
|
Trigger
|
U
|
User table
|
UQ
|
UNIQUE constraint
|
V
|
Views
|
X
|
Extended stored procedure
|
TF
|
Functions
|
Suppose you want to know how many stored procedure in a database.Then run the follwing query in database
SELECT * FROM sysobjects where xtype=’p’
It will return all the stored procedures details.
How to get the list of objects in SQL SERVER database?
Reviewed by kamal kumar das
on
January 20, 2012
Rating:
No comments: