Click here to Skip to main content
14,698,142 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 20-Jul-12 0:00am
v2

Try this...

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
   
v2
Comments
   
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 ...
Columns count:
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema=MyDatabase AND table_name = MyTable
   
Comments
Espen Harlinn 20-Jul-12 10:03am
   
5'ed!

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