how to find number of columns in a table in sql server 2000
and 2005 also

Answer Posted / anand k

--Count of Columns
SELECT COUNT(*) NO_OF_COLUMNS
FROM SYS.COLUMNS
WHERE OBJECT_ID = OBJECT_ID('<TableName>')
ORDER BY Column_ID

--Column Names
SELECT [NAME]
FROM SYS.COLUMNS
WHERE OBJECT_ID = OBJECT_ID('<TableName>')
ORDER BY Column_ID

Is This Answer Correct ?    14 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you understand by the analysis services in sql server?

702


Which are the two editions in which SQL Azure database available?

115


What is transaction server distributed transaction?

718


What are blobs, tables, and Queues? Is SQL is the standard way to query blobs, tables, and queues?

131


What is the function of inner join?

752






What is a document index?

767


How to convert numeric expression data types using the cast() function?

721


How to defragment table indexes?

698


Explain filestream storage of sql server 2008?

690


Is it possible to have clustered index on separate drive from original table location?

685


Explain the usage of floor function in sql server.

675


What protocol does sql server use?

695


What stored by the master?

716


What is user-defined function?

724


What is parameterized reports in ssrs ?

125