How to find the number of columns in a table?

Database
Enthusiast

How to find the number of columns in a table?

Hi All,
Please help me to find the count of columns in a table.

Thanks & Regards,
Md. Siddique
3 REPLIES
Enthusiast

Re: How to find the number of columns in a table?

The following SQL will do the job for you.

SELECT DatabaseName, TableName, Count(columnname) As ColumnCount
FROM DBC.Columns
WHERE DatabaseName='E_CompanyDB'
AND TableName='Employee'
GROUP BY 1,2;

-Foxbat
Enthusiast

Re: How to find the number of columns in a table?


sel count(*) from dbc.tvfields where tableid =
(Select tvmid from dbc.tvm where tvmname = 'employee'
and databaseid = (sel databaseid from dbc.dbase where databasename = 'first_ex'));
Enthusiast

Re: How to find the number of columns in a table?

Thanks for ur query