Wednesday, December 24, 2008

T-SQL : Display structure of a table

Hi all,
Last night, when i was dealing with some server side error with my module of dotnetnuke and using the SQL page of the dotnetnuke, i was trying to access structure of an sql table, i search throug the web and here is what i get:
1)using a select statement:

SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_CATALOG = 'Database name' AND
TABLE_NAME = 'Table Name'

This will display a nice table formated output of the columns with all the data associated with it.
2)Another way is:

exec sp_columns TableName

1 comment:

Please add your valuable comments about this post if it helped you. Thanks