Reputation: 21641
I'm dealing with SPROCS that return a lot of columns. However, I know what tables those columns are coming from. Once again, those tables have so many columns, not sorted alphabetically.
Knowing the table and column's names, is there a way to run a query that describe the column? I'm more interested in the type of the column, i.e. VARCHAR, INTEGER, DATETIME,...
Thank you for helping
Upvotes: 0
Views: 37
Reputation: 1789
You can query the tables from the sys
schema of the database in SQL Server like below.
Select t.name Tab_Nm, c.name as Col_Nm, ty.name as DataType, c.Max_Length, c.Precision, c.Scale, c.Is_Nullable
From sys.columns c
Inner Join sys.tables t
On c.object_id=t.object_id
Inner Join sys.types ty
On c.user_type_id=ty.user_type_id
Upvotes: 1