In today’s article we will see question of one of reader Mohan and answer from expert Imran Mohammed. Imran thank you for answering question of Mohan.
Question of Mohan:
how can i get field name and type etc. in MS-SQL server 2005. is there any query available???
Answer from Imran Mohammed:
This stored procedure gives all the details of column, their types, any indexes, any constraints, any identity columns and some good information for that particular table.
select column_name ‘Column Name’, data_type ‘Data Type’, character_maximum_length ‘Maximum Length’ from information_schema.columns where table_name = ‘table_name’
Hope this helps,
Let see Imran’s example using sample database AdventureWorks.
SELECT column_name 'Column Name',
data_type 'Data Type',
CHARacter_maximum_length 'Maximum Length'
WHERE table_name = 'Address'
Reference : Pinal Dave (http://blog.SQLAuthority.com)