Get Table and Field Names

From: Paschalis Pagonidis (anonymous_at_discussions.microsoft.com)
Date: 11/16/04


Date: Tue, 16 Nov 2004 05:58:56 -0800

You can also get table and field names using a stored
procedure.

To get a list of available tables in current database,
execute the following command:
EXEC sp_msforeachtable @command1='print ''?'''

or

EXEC sp_msforeachtable @command1='print REPLACE(REPLACE
(''?'', ''[dbo].['', ''''), '']'', '''')'

Additionally, to retrieve information about extended field
properties (like descriptions) for a table, execute the
following statement:
select * from ::fn_listextendedproperty
(null, 'user', 'dbo', 'table', '<table_name>', 'column',
default)

where <table_name> is the table name.

>-----Original Message-----
>How do I get the names of the tables in a database via
ado.net? Once I have
>the table names, how do I get the names of the Fields for
each table? I
>used to use OpenSchema in vb6 but do not find a
correlating command for
>..net. Thanks.
>
>
>.
>



Relevant Pages

  • Re: Sleep freezing
    ... >> man exec. ... > form of a standard shell pipeline where each arg becomes one ... > word of a command, and each distinct command becomes a sub- ... The word "execute" means to replace the program running in the calling ...
    (comp.unix.shell)
  • Re: Please Help
    ... "USE" command in a procedure or trigger. ... > name in the EXEC call, ... > EXEC sp_grantdbaccess @newname ... The database where the ...
    (microsoft.public.sqlserver.security)
  • Re: du command failing
    ... directory if the directory does not have a Read or Execute permission. ... From UNIX command line i have executed 'du' command. ... From [exec] manpage: ...
    (comp.lang.tcl)
  • RE: COMMAND field of TSO LOGON panel
    ... The issue is that the logon proc being executed directly launches into ISPF, ... If you exit ISPF, allow the exec to run, then reenter ISPF ... COMMAND field of TSO LOGON panel ... However,it didn't execute it. ...
    (bit.listserv.ibm-main)
  • Re: DB Space
    ... > "Hari Prasad" wrote: ... >> Can you execute the below command to ghet the actual database size. ...
    (microsoft.public.sqlserver.msde)