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 |
i need to know how i display department which has salary > =5000 for the below table Department ----------- salary deptname 1000 a 3000 a 2000 b 3000 b 4000 c 5000 c kindly send the query to thilakvinoth13@gmail.com
Why Master database is required?
What is the difference between osql and query analyzer?
Accidentally i deleted my table. How can i get that table?
How to drop existing views from a database in ms sql server?
What is a trigger in sql server?
How to delete duplicate records based on single column from a table?
0 Answers Petranics Solutions,
Write a SQL query in order to merge two different columns into single column?
Difference between report and query parameter. Why do we need different type of parameter?
How to achieve Paging of records in SQL SERVER?
0 Answers Petranics Solutions,
What is a rollup clause?
when we use function instead of procedure? plz tell me the situation with ex?