Click here to Skip to main content
15,880,469 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi experts,

Thank you for attention.


my table

id name loc branch
1 AB Kol
2 Den Den

if i give 0 as column index get 1,2

and how to get no of columns exist in a particular table


Thanks in advance.

please help
Posted
Updated 19-Jul-12 23:00pm
v2

Columns count:
SQL
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema=MyDatabase AND table_name = MyTable
 
Share this answer
 
Comments
Espen Harlinn 20-Jul-12 10:03am    
5'ed!
Try this...

SQL
SELECT COUNT(COLUMN_NAME) FROM INFORMATION_SCHEMA.COLUMNS WHERE
TABLE_CATALOG = 'database' AND TABLE_SCHEMA = 'dbo'
AND TABLE_NAME = 'table'


Here is another link

sql authority[^]

Hope it helps...

Sebastian
 
Share this answer
 
v2
Comments
Kaushik Saha from Kolkata,India 20-Jul-12 5:12am    
now,how to get value using column index not columnname
Espen Harlinn 20-Jul-12 10:03am    
5'ed!
Sebastian T Xavier 20-Jul-12 12:21pm    
Thanks ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900