How do I count the number of columns in a table in sql and display this value in web page (aspx) ? for example , i want to get the number of ID filed in sql server to display in a web page for understand how many people are member on my web site thanks
Do you mean 'count the number of rows?'
If so something like select count(id) from member_table
will give you the amount of members
SELECT COUNT(COLUMN_NAME) FROM INFORMATION_SCHEMA.COLUMNS WHERE
TABLE_CATALOG = 'database' AND TABLE_SCHEMA = 'dbo'
AND TABLE_NAME = 'table'
I am not sure what database you are using but here is MS SQL's version.
MSSQL Count Columns:
SELECT COUNT(COLUMN_NAME) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_CATALOG = 'database' AND TABLE_SCHEMA = 'dbo' AND TABLE_NAME = 'table'
But I suspect you mean Rows?
SELECT COUNT(column_name) FROM table_name
e.g.:
SELECT COUNT(id) FROM users
will return you a number of registered users