To get total number of columns in a table in sql

后端 未结 9 1438
清酒与你
清酒与你 2021-01-30 13:05

I need a query in sql to get total columns in a table.Can anybody help?

9条回答
  •  死守一世寂寞
    2021-01-30 13:13

    This query gets the columns name

    SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.Columns where TABLE_NAME = 'YourTableName'
    

    And this one gets the count

    SELECT Count(*) FROM INFORMATION_SCHEMA.Columns where TABLE_NAME = 'YourTableName'
    

提交回复
热议问题