Describe, or desc in short, is one of the most valuable commands when trying to understand a database structure. MsSql lacks this feature so you have to write it yourself.
SELECT column_name , data_type + COALESCE( '(' + CAST(character_maximum_length AS VARCHAR) + ')' , '(' + CAST(numeric_precision AS VARCHAR) + ')' , '' ) , column_default , is_nullable FROM information_schema.columns WHERE table_name = 'tablename';
Also see Getting a table description.
@acn: You probably mean
or even better
This indeed works.
sp_columns tablename
is equivalent command for DESC from Oracle.
MS-sql doesnot lack desc
Nice one… Still we can modify this to short as follows…
select column_name,data_type from information_schema.columns where table_name = ‘your table name’;
Nice one. Did not know MSSQL lacked DESCRIBE capability. Thanks.
Nice solution! Thanks
Thanks for posting this. You just saved me hours of banging my head against a pesky MSSQL db.
Thank you, this is great.
Thank you very much. It’s is very refreshing to find a result that is upfront and straight to the point for once.
-Duane