How to list all objects of a particular database in SQL Server
metadata, sql-server, t-sql
Solution
Which database are you running this in? When I run it in a particular database, I don't get anything outside that database.
Problem
I would like to list all objects of a particular database in SQL Server. 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 list all objects of ALL databases rather than a particular database. My question is: Is there a way to query all objects of just a particular database?