google

Find the number of columns in a Table in MS-SQL

| Thursday, March 12, 2020
Following script can be used to find the number of columns in a table.


SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS 
WHERE table_catalog = 'name_of_database' -- the database
   AND table_name = 'name_of_table'


e.g 
Use Hospital
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS 
WHERE table_catalog = 'Hospital' -- the database   AND table_name = 'User'

0 comments:

Post a Comment

Prev
▲Top▲