Listing indexes using sys.indexes and index_columns, and using a derived query in the FROM clause

preview_player
Показать описание
How can you list all the indexes used in your database? And how can use use a subquery in your FROM clause? And how can we JOIN three things together.

My SQL Server Udemy courses are:
----
Following on from the previous video (which you should watch first, if you haven't already), we'll have a look at how to extract all of the indexes used in your database. Additionally, we will use the query we created in the previous video in the FROM clause to JOIN with another query. We will also add another JOIN as well in our query.
Here is the finished code we will create:

SELECT I.name AS IndexName, I.type_desc as IndexTypeDesc
, C.ObjectName, C.TypeDesc, C.ColumnName
, IC.*
ON I.object_ID = IC.object_ID and I.index_ID = IC.index_ID
JOIN (
SELECT SCHEMA_NAME(O.schema_id) + '.' + O.name AS ObjectName, T.name AS TypeDesc, C.name as ColumnName
, C.object_ID, C.column_ID
ON C.object_id = O.object_id ) AS C
ON IC.object_id = C.object_id AND IC.column_id = C.column_ID
Рекомендации по теме
Комментарии
Автор

I searched for this video for hours and now I finally got it .. thank you for explaining!!!

Ekmevadwitiyam
visit shbcf.ru