Get field name, data type and size of database table

Shailendra Chauhan  Print 
Posted On : 31 Aug 2012
Updated On : 24 Sep 2016
Total Views : 185,135

One student of me asked "how can we get fields name of a table with theirs 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' 
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.



Free Interview Books
 
COMMENTS
jason Reply 526 days 3 hours 17 mins ago

Hi please help me VB.NET source program that could get a name of database SQL Server file from user and show all tables and fields and size and also SP , view . please send me to email

SUBSCRIBE OUR YOUTUBE CHANNEL
 
 
 
LIKE US ON FACEBOOK
 
+