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

Define DML and DCL statements?

1 Answers   Hexaware, NIIT,


Is SET a SQL Keyword?

4 Answers   BitWise,


How can we use ConnectorJ JDBC Driver with MS SQL?

0 Answers   PUCIT,


If a table does not have a unique index, can a cursor be opened on it?

0 Answers  


in my server i have 3 instances,one of them got failed, and this cause we r not able to connect to server, how to know which instance was dameged?

1 Answers   IBM,






Can sql server be linked with other servers like oracle?

0 Answers  


What is Pointer ?

3 Answers   Cap Gemini, CarrizalSoft Technologies,


i want to create procedure for create table in sql server 2005 for example create procedure create_table @table varchar(20) as create @table( id int, name char(20) ) but it will get error what is solution?

5 Answers   Aptech,


what is bit data type? and what are the information that can be stored inside a bit column?

2 Answers  


What do you know about normalization and de- normalization?

0 Answers  


tell me the disaster recovery plan

0 Answers   Microsoft,


How many .ndf files can we create in Sql server 2005?

2 Answers   Wipro,


Categories