Thursday, 9 August 2018

SQL Server Sys object Query

            Sys.Objects content list of object that has been created by user and system itself. Sys.Objects contain row for each user defined  object that has been created within a database.

             Sys.Object has several column to hold data with each as unique identification number. 



 
Below is the list of column

name : name of the object create a table in a database.
object ID : Unique Identification number of a object.
type : type of object ,it is  two character long  to define type. 


Below is the list of type.
D = DEFAULT (constraint or stand-alone)
F = FOREIGN KEY constraint
P = SQL Stored Procedure
PK = PRIMARY KEY constraint
U = Table (user-defined)
V = View
UQ=Unique constraint



Now we are going to learn some  Sys.Objects query

1)Below query return all tables created by user.



SELECT * FROM sys.objects where type='U'

2)
Below query return all tables created by user with name like condition.

SELECT * FROM sys.objects where type='U' and name like 'stu%'

3)Below query return all store procedure created by user.

SELECT * FROM sys.objects where type='P'

4)Below query return all View created by user.


SELECT * FROM sys.objects where type='V'

5)Below query return all primary key created by user. 
 
SELECT * FROM sys.objects where type='PK'

No comments:

Post a Comment

বাঙালির বেড়ানো সেরা চারটি ঠিকানা

  বাঙালি মানে ঘোড়া পাগল | দু একদিন ছুটি পেলো মানে বাঙালি চলল ঘুরতে | সে সমুদ্রই হোক , পাহাড়ি হোক বা নদী হোক। বাঙালির ...