SQL SERVER: Find number of columns in a table

Posted: July 26, 2012 in SQL Server
Tags: , , , , , , , , ,

The post contains a simple query to find the number of columns in your sql sever table.


SELECT COUNT(COLUMN_NAME) FROM INFORMATION_SCHEMA.COLUMNS WHERE
TABLE_CATALOG = 'databse_name' AND TABLE_SCHEMA = 'dbo'
AND TABLE_NAME = 'table_name'

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s