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

Answers were Sorted based on User's Feedback



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

Answer / harshad

select count(*) from information.schema.columns
where table_name='tablename'

//where tablename is name of your sql table.
//do not prefix table name with .dbo

Is This Answer Correct ?    2 Yes 0 No

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

Answer / mohan

Guys.. Why don;t you try for the Columns bided with User
Defined Data Type and try the above queries... and Also try
for the Auto incremented Columns..(Identity)....
Your opinion would change definately....
Try out...
I am sure it doesn't take account of UDT Binded Coulmns

Is This Answer Correct ?    3 Yes 2 No

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

Answer / ajit kumar nayak

select count(*) from syscolumns sy,Sysobjects so
where
sy.id =so.id
and so.name = <table name>

Is This Answer Correct ?    1 Yes 0 No

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

Answer / ram&saran

SELECT COUNT(*) FROM SYS.COLUMNS WHERE ID=(SELECT * FROM
SYS.OBJECT WHERE NAME='TABLENAME')

Is This Answer Correct ?    1 Yes 1 No

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

Answer / laxmi reddy

SELECT COUNT(COLUMN_NAME) FROM ALL_TAB_COLS WHERE
TABLE_NAME=<'TABLE_NAME'>;

Is This Answer Correct ?    0 Yes 0 No

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

Answer / ashutosh jha

select count (*) from tablename.

Is This Answer Correct ?    7 Yes 134 No

Post New Answer

More SQL Server Interview Questions

You have to store user responses of ‘yes’ and ‘no’ what kind of data type is best suited for this task?

0 Answers  


why SQL server is more used to store database rather than Access

2 Answers  


Explain system rowset functions?

0 Answers  


How can you control the amount of free space in your index pages?

0 Answers  


Is there any difference between primary key and unique with the not null condition?

0 Answers  






What are user defined functions in ms sql server?

0 Answers  


what is web server?

3 Answers   Satyam,


What is GUID in sql server?

0 Answers   BirlaSoft,


What are the advantages dts has over bcp?

0 Answers  


What are the differences between stored procedure and functions in SQL Server 2000?

25 Answers   College School Exams Tests, HCL, Infosys, TCS,


What is the difference between a view and a stored procedure?

0 Answers  


How do you use DBCC statements to monitor various aspects of a SQL server installation?

1 Answers  


Categories