Link to home
Start Free TrialLog in
Avatar of borg48
borg48

asked on

How to get column names an types from a sql statement

If a stored procedure that just returns a select statement or an embededded sql:

select * from test_table;

How do you do it in ado.net to figure out the column names and its data types?

For example test_table has the columns first_name varchar(15), mi char(1), last_name varchar(25), date_created datetime.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of osiris247
osiris247
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of YZlat
SELECT syscolumns.name AS ColName, systypes.name AS ColType, syscolumns.length AS ColSize
FROM sysobjects INNER JOIN syscolumns ON sysobjects.id = syscolumns.id
INNER JOIN systypes ON dbo.syscolumns.xtype = dbo.systypes.xtype
WHERE sysobjects.xtype='U' AND sysobjects.name='Table1'