Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I need to find names of all the tables in a DB, name of the indexes present, size of the index, and the columns in that index in a single query. I've got separate queries for finding all these. But i need to find them using a single query. how do i do this?
Posted

1 solution

Hello


SQL
select t.name as Tbl_Name ,i.type_desc as Indextype ,c.name as column_name ,ty.name as datatypes,c.max_length as ColumnSize from  sys.tables t
JOIn sys.indexes i
ON t.object_id =	i.object_id 
JOIN sys.index_columns ic
ON ic.object_id =	i.object_id 
and	i.index_id	=	ic.index_id 
JOIN sys.columns c
ON	c.object_id		=	ic.object_id 
AND	c.column_id		=	ic.column_id 
JOIN sys.types  Ty
On c.user_type_id	=	ty.user_type_id


Pls check it will help you.

Vote if u clear.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900