SELECT count(*) from information_schema.columns where table_name='giveTableNameHere'
orSELECT count(*) FROM syscolumns WHERE OBJECT_NAME(id) = 'giveTableNameHere'
here i given my tested query for counting columns in a particular Table in a DB
dot net tips, DotNet tips, .Net Tips,Dot Net tips and tricks,Dot Net Solutions, OOPS Concept in C#,SQL Server, LinQ, Ajax, Java script, JQuery, Server Error details, daily .net tips and tricks , DotNet Interview Questions.
emp_id | emp_name | emp_manager_id |
1 | Vinoth | Null |
2 | Prabhu | 1 |
3 | Prabha | 1 |
4 | Saravanan | 2 |
5 | Babu | 2 |
6 | Muthu | 5 |
7 | Dinesh | 5 |
manager | employee |
Vinoth | Prabhu |
Vinoth | Prabha |
Prabhu | Saravanan |
Prabhu | Babu |
Babu | Muthu |
Babu | Dinesh |