Friday, March 4, 2016

Database : Get field name, data type and size of database table

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

  1. SELECT column_name as 'Column Name', data_type as 'Data Type',
  2. character_maximum_length as 'Max Length'
  3. FROM information_schema.columns
  4. WHERE table_name = 'tblUsers'

No comments:

Post a Comment