To get total number of columns in a table in sql

后端 未结 9 1334
清酒与你
清酒与你 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:25

    Correction to top query above, to allow to run from any database

    SELECT COUNT(COLUMN_NAME) FROM [*database*].INFORMATION_SCHEMA.COLUMNS WHERE 
    TABLE_CATALOG = 'database' AND TABLE_SCHEMA = 'dbo'
    AND TABLE_NAME = 'table'
    

提交回复
热议问题