Retrieving a list of SQL Server objects (constraints, tables, views, functions) using sys.objects

Published: 18 November 2021
on channel: SQL Server 101
15,434
113

How can you retrieve a list of all of your constraints, functions, tables, procedures and views? It's very easy.
My SQL Server Udemy courses are:
70-461, 70-761 Querying Microsoft SQL Server with T-SQL: https://rebrand.ly/querying-microsoft...
98-364: Database Fundamentals (Microsoft SQL Server): https://rebrand.ly/database-fundamentals
70-462 SQL Server Database Administration (DBA): https://rebrand.ly/sql-server-dba
Microsoft SQL Server Reporting Services (SSRS): https://rebrand.ly/sql-server-ssrs
SQL Server Integration Services (SSIS): https://rebrand.ly/sql-server-ssis
SQL Server Analysis Services (SSAS): https://rebrand.ly/sql-server-ssas-mdx
Microsoft Power Pivot (Excel) and SSAS (Tabular DAX model): https://rebrand.ly/microsoft-powerpiv...
----
You can get a list of SQL Server objects very easily using SELECT * FROM sys.objects . This includes check, default, primary key and foreign key constraints.
However, you can develop it very easily, by getting the Schema Name and the Parent Object Name - for example, what table a constraint is in? The code I develop in this video is:
SELECT Schema_NAME(O.schema_id) as SchemaName, object_name(O.parent_object_id) as ParentObjectName, O.*
FROM sys.objects AS O


On this page of the site you can watch the video online Retrieving a list of SQL Server objects (constraints, tables, views, functions) using sys.objects with a duration of hours minute second in good quality, which was uploaded by the user SQL Server 101 18 November 2021, share the link with friends and acquaintances, this video has already been watched 15,434 times on youtube and it was liked by 113 viewers. Enjoy your viewing!