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
Explain what stored procedure sp_replcounters is used for? : sql server replication
what information is maintained within the msdb database? : Sql server administration
Can we insert data if clustered index is disabled?
How to call stored procedure using http soap?
What is difference between rollback immediate and with no_wait during alter database?
What is the purpose of floor function?
How to recover from sql injection? : sql server security
what stored procedure can you use to display the current processes? : Sql server administration
What are the differences between char and nchar in ms sql server?
Does windows server 2016 come with sql server?
What is for xml in sql server?
Which are the new data types introduced in sql server 2008?
optimization techinques
What do you mean by the term 'normalization'?
How does recursive cte works in sql server?