Get field name, data type and size of database table

Shailendra Chauhan  Print   1 min read  
31 Aug 2012
12 Apr 2019
Intermediate
196K

One student of mine asked, "how can we get fields name of a table with their type and size ?". In this article I am going to expose, how can we achieve this in SQL Server.

Query to get field name with datatype and size

 SELECT column_name as 'Column Name', data_type as 'Data Type',
character_maximum_length as 'Max Length'
FROM information_schema.columns
WHERE table_name = 'tblUsers' 
Read More Articles Related to SQL Server
Summary

In this article, I explain how can you get fields of a database table. I hope after reading this article you will be able to do this. I would like to have feedback from my blog readers. Please post your feedback, question, or comments about this article.

Learn to Crack Your Technical Interview

 
Learn to Code

Start your journey today to learn coding!


Because learning to code is the first step and foreward to advance your career.


 GET STARTED NOW