dbTalk Databases Forums  

descibe tables in sqlcmd

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss descibe tables in sqlcmd in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
björn lundin
 
Posts: n/a

Default descibe tables in sqlcmd - 06-12-2011 , 09:25 AM






Hi!
In other databases, the prompt-tool offers a way of doing dml/ddl
statements.
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=# \d
List of relations
Scheme | Name | Type | Owner
--------+------------+--------+-------
public | programmes | tabell | bnl
(1 row)

eyetv=# \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 |
Index:
"programmes_pkey" PRIMARY KEY, btree (start, stop, channel)

eyetv=#

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

--
Björn

Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: descibe tables in sqlcmd - 06-12-2011 , 01:32 PM






björn lundin (b.f.lundin (AT) gmail (DOT) com) writes:
Quote:
In other databases, the prompt-tool offers a way of doing dml/ddl
statements.
They usually have a way of describing objects in the db as well
I have not found that with sqlcmd yet.
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 (AT) sommarskog (DOT) 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

Reply With Quote
  #3  
Old   
björn lundin
 
Posts: n/a

Default Re: descibe tables in sqlcmd - 06-12-2011 , 03:04 PM



On 12 Juni, 20:32, Erland Sommarskog <esq... (AT) sommarskog (DOT) se> wrote:
Quote:
björn lundin (b.f.lun... (AT) gmail (DOT) com) writes:
In other databases, the prompt-tool offers a way of doing dml/ddl
statements.
They usually have a way of describing objects in the db as well
I have not found that with sqlcmd yet.

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.
Ok, thanks.
Then it is possible to write a stored proc, quering the views
directly.
Good hint
--
Björn

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.