Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing table design

Status
Not open for further replies.

EscapeUK

Programmer
Jul 7, 2000
438
GB
How do I print the design of the table. All I need is the field name, field type and field length
 
If you open your table under ADODB or DAO, then you can get at the fields collection.

Example:
Dim rst As New Recordset, cnn As ADODB.Connection
Set cnn = CurrentProject.Connection
Dim indx As Integer

''Open the table and the fields are accessible
rst.Open "Export852Heading", cnn

'- data type descriptions are in: DataTypeEnum.adVarWChar

For indx = 0 To (rst.Fields.Count - 1)
Debug.Print "Name = "; rst.Fields(indx).Name
Debug.Print "Type = "; rst.Fields(indx).type
Debug.Print "ActualSize = "; rst.Fields(indx).ActualSize
Debug.Print "DefinedSize = "; rst.Fields(indx).DefinedSize
Next '-- end for
 
If you are working in Query Analyzer you can look in the sysobjects, syscolumns, and systypes tables. To get the name you can use this example, but you will need to add type and length.

select SO.Id,
TableName = SO.Name,
ColumnName = SC.name
from Sysobjects SO
Inner join Syscolumns SC on SO.id = SC.id
where SO.TYpe = 'U'
order by SO.Name
 
I recommend looking into the Information_schema views if you use SQL 7 or later.

Example: List columns in Employees Table

Select
Column_Name, Data_type,
Data_Length=Isnull(NUMERIC_PRECISION, CHARACTER_MAXIMUM_LENGTH)
From DBName.information_schema.columns
Where Table_name='Employees' Terry L. Broadbent
Programming and Computing Resources
 
Actually, Structured Query Language, like most things in the computing world, has been shortened to SQL. Basically, SQL is a standardized language for retrieving and manipulating data in relational databases.

I recommend that you start a new thread rather than add to an exisiting thread if you have a new. This is especially important if your question is off the topic of the thread. Terry L. Broadbent
Programming and Computing Resources
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top