Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filtering SQL Server sys.objects by database

Should be easy, but I can't get it.

I want to filter the sys.objects results by database (either name or id). I thought I had to join with sys.databases, but does not seem to be possible. I went to SQL Servers docs but did not find anything that could help.

What am I missing?

like image 336
MatteoSp Avatar asked Mar 19 '12 09:03

MatteoSp


1 Answers

Each Database have its own sys.objects, so you have to get the databases from sys.databases, and

select from {dbname}.sys.objects

{dbname} is the name from sys.databases

like image 165
Jaques Avatar answered Oct 02 '22 21:10

Jaques