how to find number of columns in a table in sql server 2000
and 2005 also
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
Answer / laxmi reddy
SELECT COUNT(COLUMN_NAME) FROM ALL_TAB_COLS WHERE
TABLE_NAME=<'TABLE_NAME'>;
Is This Answer Correct ? | 0 Yes | 0 No |
What is the contrast between sql and pl/sql?
What is the beast way to write CTE in SQL Server ?
You have developed an application which uses many stored procedures and triggers to update various tables users ocassionally get locking problems which tool is best suited to help you diagnose the problem?
Define DML and DCL statements?
How to create an index on a view?
can any one please send sql quries most used in applications.
What is an index. What are the types?
What is the use of partition by in sql server?
How to find which stored procedure is currently running in sql server?
What is RAID and what are different types of RAID configurations?
What is meant by Active-Passive and Active-Active clustering setup?
What is stretch database in sql server?