如何在SQL Server 2005中列出特定数据库的所有对象

时间:2021-10-05 09:27:33

I'd like to list all objects of a particular database in SQL Server 2005. I created a query as shown below:

我想在SQL Server 2005中列出特定数据库的所有对象。我创建了一个查询,如下所示:

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? If yes, could you please show me how to do it?

我的问题是:有没有办法查询特定数据库的所有对象?如果是的话,请你告诉我该怎么做?

1 个解决方案

#1


Which database are you running this in? When I run it in a particular database, I don't get anything outside that database.

你在哪个数据库中运行它?当我在特定数据库中运行它时,我没有得到该数据库之外的任何内容。

#1


Which database are you running this in? When I run it in a particular database, I don't get anything outside that database.

你在哪个数据库中运行它?当我在特定数据库中运行它时,我没有得到该数据库之外的任何内容。