How to list all objects of a particular database in SQL Server
This is what I use.
SELECT o.type_desc AS Object_Type
, s.name AS Schema_Name
, o.name AS Object_Name
FROM sys.objects o
JOIN sys.schemas s
ON s.schema_id = o.schema_id
WHERE o.type NOT IN ('S' --SYSTEM_TABLE
,'PK' --PRIMARY_KEY_CONSTRAINT
,'D' --DEFAULT_CONSTRAINT
,'C' --CHECK_CONSTRAINT
,'F' --FOREIGN_KEY_CONSTRAINT
,'IT' --INTERNAL_TABLE
,'SQ' --SERVICE_QUEUE
,'TR' --SQL_TRIGGER
,'UQ' --UNIQUE_CONSTRAINT
)
ORDER BY Object_Type
, SCHEMA_NAME
, Object_Name
Which database are you running this in? When I run it in a particular database, I don't get anything outside that database.
List all procs, views, tables, functions in 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
The comment is if you want to search for a particular (whole) word.