I have two tables, customers
and orders
.
I would like a query to list all the columns from customers and orders and list whether or not the columns are indexed.
I am assuming I need to make use of sys.columns
and sys.indexes
but cannot understand how to create the proper query.
Customer table:
CustomerId (primary key, clustered index) Name Address PostalCode (non-unique, non-clustered index)
Orders table:
OrderId (primary key, clustered index) CustomerId (non-unique, non-clustered index) Description CompanyId (non-unique, non-clustered index)
Query results should look like:
column name | indexed -------------+------------ CustomerId | true Name | false Address | false PostalCode | true OrderId | true CustomerId | true Description | false CompanyId | true
https://stackoverflow.com/questions/67307868/using-t-sql-how-can-i-list-the-columns-of-two-tables-and-indicate-whether-or-no April 29, 2021 at 05:04AM
没有评论:
发表评论