[dba-SQLServer] Table Definition

Billy Pang tuxedo_man at hotmail.com
Sat Aug 28 12:13:53 CDT 2004


You can get all column defs for all columns in all tables of current user db 
from running the following query:

SELECT * FROM INFORMATION_SCHEMA.columns


>From: "Ken Stoker" <kens.programming at verizon.net>
>Reply-To: dba-sqlserver at databaseadvisors.com
>To: "'Joseph O'Connell'" <joconnell at indy.rr.com>,   
><dba-sqlserver at databaseadvisors.com>
>Subject: RE: [dba-SQLServer] Table Definition
>Date: Fri, 27 Aug 2004 11:05:53 -0700
>
>I have always copied the results out to Excel and worked with it from 
>there.
>The column names aren't included in the copy/paste, so you will need to put
>those in if you need them.
>
>One other thing, the query I provided doesn't return fields with user
>defined types.  I did some more playing around and the best way is to
>replace sc.xtype = st.xusertype with sc.xusertype = st.xusertype.
>
>Ken
>
>-----Original Message-----
>From: Joseph O'Connell [mailto:joconnell at indy.rr.com]
>Sent: Friday, August 27, 2004 10:43 AM
>To: dba-sqlserver at databaseadvisors.com; kens.programming at verizon.net
>Subject: Re: [dba-SQLServer] Table Definition
>
>Ken,
>
>Thank you for your prompt reply.  This query does give me the information
>that I need.
>
>Is there an easy way to print the results of the query?
>
>Joe O'Connell
>
>-----Original Message-----
>From: Ken Stoker <kens.programming at verizon.net>
>To: dba-sqlserver at databaseadvisors.com <dba-sqlserver at databaseadvisors.com>
>Date: Friday, August 27, 2004 12:10 PM
>Subject: RE: [dba-SQLServer] Table Definition
>
>
>|Will this work for you?
>|
>|SELECT so.name AS TableName, sc.name AS FieldName, st.name AS Type,
>| sc.Length, sc.Prec, sc.Scale
>|FROM sysobjects so INNER JOIN syscolumns sc on so.id = sc.id
>| INNER JOIN systypes st on sc.xtype = st.xusertype
>|WHERE so.name = 'mytablename'
>|
>|Ken
>|
>|-----Original Message-----
>|From: dba-sqlserver-bounces at databaseadvisors.com
>|[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Joseph
>|O'Connell
>|Sent: Friday, August 27, 2004 9:33 AM
>|To: dba-sqlserver at databaseadvisors.com
>|Subject: [dba-SQLServer] Table Definition
>|
>|In an Access application, I can use the Documenter tool to generate a
>report
>|of table definitions.
>|
>|Is there an equivalent tool in SQL Server that will easily create a report
>|showing the Name, Data Type and Size of the fields in a selected table?
>|
>|Joe O'Connell
>|
>|
>|
>|_______________________________________________
>|dba-SQLServer mailing list
>|dba-SQLServer at databaseadvisors.com
>|http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
>|http://www.databaseadvisors.com
>|
>|_______________________________________________
>|dba-SQLServer mailing list
>|dba-SQLServer at databaseadvisors.com
>|http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
>|http://www.databaseadvisors.com
>|
>
>
>_______________________________________________
>dba-SQLServer mailing list
>dba-SQLServer at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
>http://www.databaseadvisors.com
>

_________________________________________________________________
Take advantage of powerful junk e-mail filters built on patented Microsoft® 
SmartScreen Technology. 
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines 
  Start enjoying all the benefits of MSN® Premium right now and get the 
first two months FREE*.




More information about the dba-SQLServer mailing list