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 is read uncmmited?
What happens if null values are involved in bitwise operations?
What is the standby server?
What is a field name?
List the ways in which dynamic sql can be executed?
what exactly sql injuction.how to overcome.....
List out the different types of locks available in sql server?
Tell me what is the order in which the sql query is executed?
Can you please explain the difference between primary keys and foreign keys?
How do I find the sql server version?
What are system databases into sql server (2005/2008) : sql server database administration
Can You Use Data Mining Models In Ssrs?
Does group by sort data?
What is difference between rownum and row_number?
How to use "begin ... End" statement structures in ms sql server?