How to find number of column in a table in different database.

dhirenkaunar-15094
Posted by dhirenkaunar-15094 under Sql Server category on | Points: 40 | Views : 1398
The below query will return number of column contain by each table in database
Oracle:
select table_name,count(*) '# of column' from user_tab_cols  group by table_name order by table_name asc;

Sql server

select COUNT(*),TABLE_NAME from Information_schema.COLUMNS
group by TABLE_NAME
order by TABLE_NAME


If you want to searching # of column in a particular table then use where condition as mentioned below :
Oracle :
select table_name,count(*) from user_tab_cols
where upper(table_name)='HELP' group by table_name order by table_name asc;

Sql Server
select COUNT(*),TABLE_NAME from Information_schema.COLUMNS
where upper(table_name)='Course'
group by TABLE_NAME
order by TABLE_NAME

Comments or Responses

Login to post response