Script to get a list of the columns in a table along with the data type, size of each of those columns

Posted by Niladri.biswas under Sql Server category on | Points: 40 | Views : 2231
[Table Name] = t.Name
,[Column Names] = c.Name
,[Data Type] =
,[Size] = c.max_length
,[Is Identity] = c.is_identity
,[Column Order] = c.column_id
From sys.tables t
Join sys.columns c
On t.object_id = c.object_id
Join sys.types sc
On c.system_type_id = sc.system_type_id
Where t.Name = 'The Table Name'
Order By c.column_id

Comments or Responses

Login to post response