Friday 9 November 2012

how to get the count of columns of tables in sql



Get the number of columns in the table

Use [yourdatabaseName]

SELECT COUNT(*)
FROM information_schema.columns
WHERE table_name = 'yourtableName'

OR

SELECT COUNT(*)
FROM yourdatabaseName.sys.columns
WHERE object_id = OBJECT_ID('yourdatabaseName.dbo.yourtableName')