Hi,
I need to get a list of columns and corresponding datatypes for the
given table name. I am using the query:
select
a.name,
b.type_name
from
syscolumns a,
master.dbo.spt_datatype_info b,
systypes c,
sysobjects d
where
a.xusertype = c.xusertype and
b.ss_dtype = c.xtype and
a.ID = (SELECT OBJECT_ID(<tablename>)) and
a.ID = d.ID and
d.ID = (SELECT OBJECT_ID(<tablename>))
This returns multiple sets of data for each column. This is because
the same column name is repeated in multiple tables in primary
key-foreign key relationships. Is there a way in which I can get only
one row for each column of a table?