How to list all objects of a specific database in SQL Server 2005

I would like to list all the objects of a specific database in SQL Server 2005. I created a query as shown below:

select name, type_desc from sys.objects 
WHERE type in ( 'C', 'D', 'F', 'L', 'P', 'PK', 'RF', 'TR', 'UQ', 'V', 'X' ) 
union
select name, type_desc from sys.indexes
order by name

However, this query lists all objects of ALL databases, not a specific database.

My question is: is there a way to query all objects of only a specific database? If so, could you show me how to do this?

+8
source share
2 answers

What database are you working in? When I run it in a specific database, I do not get anything outside of this database.

+7
source

List of all objects on the Sql server:

SELECT DISTINCT
       o.name AS Object_Name,
       o.type_desc
  FROM sys.sql_modules m
       INNER JOIN
       sys.objects o
         ON m.object_id = o.object_id
 --WHERE  '.' + m.definition + '.' LIKE '%[^a-z]employeeid[^a-z]%'
 order by type_desc, object_name

, () .

0

All Articles