how to find number of columns in a table in sql server 2000
and 2005 also
Answer Posted / anand k
--FOR Given Table Name.
SELECT COUNT(*) FROM SYS.COLUMNS
WHERE ID = OBJECT_ID('<TABLENAME>')
--For All UD Tables in the current DB
SELECT OBJ.NAME,COUNT(*)
FROM SYS.COLUMNS COL,SYS.OBJECTS OBJ
WHERE OBJ.OBJECT_iD = COL.OBJECT_ID
AND TYPE = 'U'
GROUP BY OBJ.NAME
Is This Answer Correct ? | 4 Yes | 4 No |
Post New Answer View All Answers
What are the basic functions for master, msdb, model, tempdb databases?
What is a trace frag?
What is a data collection table?
What is replication and database mirroring?
What are the database roles? : sql server security
how do you implement one-to-one, one-to-many and many-to-many relationships while designing tables? : Sql server database administration
How do we know if any query is retrieving a large amount of data or very little data?
Tell me what is the order in which the sql query is executed?
how to invoke a trigger on demand? : Sql server database administration
What is right outer join in sql server joins?
What is the partitioning method?
What are distinctive joins find as a part of sql?
What is field with example?
What do you understand by user-defined function in the sql server?
How to turn on the mssql api module in php?