SQL Server - descibe tables in sqlcmd

Asked By björn_lundin on 12-Jun-11 10:25 AM
In other databases, the prompt-tool offers a way of doing dml/ddl
They usually have a way of describing objects in the db as well
I have not found that with sqlcmd yet.

in sql*plus (oracle) I write desc table_name and get a description of
the table.
in psql (postgresql) I write \d table_name instead, as in
eyetv=3D# \d
List of relations
Scheme |    Name    |  Type   | Owner
public | programmes | tabell | bnl
(1 row)

eyetv=3D# \d programmes
Tabell "public.programmes"
column    |             Type            | Modifier
start       | timestamp without time zone | not null
stop        | timestamp without time zone | not null
channel     | text                        | not null
title       | text                        | not null
category    | text                        |
episode     | text                        |
description | text                        |


(yes I translated the headlines, so they may be incorrect)


Erland Sommarskog replied to björn_lundin on 12-Jun-11 02:32 PM
bj?rn lundin (b.f.lundin@gmail.com) writes:

Try "EXEC sp_help 'tbl'". Which you can shorten to "sp_help tbl", as long
as there is no schema component in the name.

Although, Microsoft is moving away from the sp_helpxxx procedures, why new
features may not be presented in these. Rather, MS thinks it better to query
the catalog views directly.

Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
björn_lundin replied to Erland Sommarskog on 12-Jun-11 04:04 PM

Ok, thanks.
Then it is possible to write a stored proc, quering the views
Good hint