Hi David,
In SQL Server 2000, you can consider using the following SQL commands to
retrieve the detailed column information in the data table:
================================================
select user_name(a.uid) as username
,b.name as colname
,h.id as primarykey
,type_name(b.xusertype) as type
,b.length
,b.isnullable as [isnull]
,isnull(e.text,'') as [default]
,isnull(c.value,'') as description
from sysobjects a,syscolumns b
left outer join sysproperties c on b.id = c.id and b.colid = c.smallid
left outer join syscomments e on b.cdefault = e.id
left outer join (select g.id,g.colid from sysindexes f,sysindexkeys g where
f.id = g.id and f.indid = g.indid and f.indid > 0 and f.indid < 255 and
(f.status&2048)<>0) h on b.id = h.id and b.colid = h.colid
where a.id = b.id
and object_name(a.id) = 'TableName' and user_name(a.uid)= 'SchemaName'
order by b.colid
================================================
In SQL 20005/2008, to retrieve the column type as well, please refer to the
following SQL commands:
================================================
select sys.columns.name as ColumnName,
sys.types.name as ColumnType,
(select value from sys.extended_properties where
sys.extended_properties.major_id = sys.columns.object_id
and sys.extended_properties.minor_id = sys.columns.column_id) as
ColumnDescription
from sys.columns, sys.tables, sys.types,sys.schemas where
sys.columns.object_id = sys.tables.object_id and
sys.columns.user_type_id=sys.types.user_type_id and
sys.tables.schema_id=sys.schemas.schema_id and
sys.tables.name= 'TableName' and sys.schemas.name = 'SchemaName'
================================================
Besides, for the PK/FK question, let¡¯s discuss it in detail in your
another newsgroup case: [How do I get all FK:PK mappings with the schema
info?].
If you have any questions or concerns, please feel free to let me know.
Have a nice day!
Best Regards,
Lingzhi Sun
Microsoft Online Community Support
=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(E-Mail Removed).
This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================