Listing columns using sys.columns, and creating a SELECT statement JOINing three tables

Published: 25 November 2021
on channel: SQL Server 101
4,074
36

How easy is it to list columns in every table in your database? 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...
----
In this video, we'll have a look at the sys.columns system table. We'll also see how it can be joined to the sys.types and sys.objects tables.
The final code that we develop is:
SELECT T.[name] as Type, SCHEMA_NAME(O.schema_id) + '.' + object_name(C.object_id) as ObjectName, C.*
FROM sys.columns AS C
LEFT JOIN sys.types AS T
ON C.system_type_id = T.system_type_id AND C.user_type_id = T.user_type_id
LEFT JOIN sys.objects AS O
ON C.object_id = O.object_id


Watch video Listing columns using sys.columns, and creating a SELECT statement JOINing three tables online, duration hours minute second in high quality that is uploaded to the channel SQL Server 101 25 November 2021. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 4,074 times and liked it 36 visitors.