How to get Total count of records from database?
-
Hi All, I just want to know how to get the total number of records in the database, i.e from the perticular table, total number of records stored in the table. Please can any one help me. :(
chandu
HI, SELECT COUNT(*) FROM TABLENAME;
Thanks and Regards, Chetan Ranpariya
-
Hi All, I just want to know how to get the total number of records in the database, i.e from the perticular table, total number of records stored in the table. Please can any one help me. :(
chandu
hi chandu, To get a total number of records fire this query select count(*) from tableName hope it helps -koolprasad2003:)
If the message is useful for U then please Rate This message... Be a good listener...Because Opprtunity knoughts softly...N-Joy
-
Hi All, I just want to know how to get the total number of records in the database, i.e from the perticular table, total number of records stored in the table. Please can any one help me. :(
chandu
I could be wrong, but rather than use the suggestions above, I think it is quicker / more efficient (for large databases anyway) to use something like select count(ID) from [tableName] Assuming your table has an ID field.... (otherwise, I dare say any fieldname would do, but again, an Int type probably would be most efficient.) Someone may correct me.... Fred
-
I could be wrong, but rather than use the suggestions above, I think it is quicker / more efficient (for large databases anyway) to use something like select count(ID) from [tableName] Assuming your table has an ID field.... (otherwise, I dare say any fieldname would do, but again, an Int type probably would be most efficient.) Someone may correct me.... Fred
-
Same way you print anything... you have to read the result into a variable and print it. You can use the ExecuteScalar command on a Command object to read the number directly into a variable - eg, in VB, SQLServer: Dim objCmd As SqlCommand Dim n As Integer, s As String ... objCmd.CommandText = "SELECT COUNT(ID) FROM TableName" n = objCmd.ExecuteScalar ... s = "There are " & n.ToString & " records in the database."
-
Same way you print anything... you have to read the result into a variable and print it. You can use the ExecuteScalar command on a Command object to read the number directly into a variable - eg, in VB, SQLServer: Dim objCmd As SqlCommand Dim n As Integer, s As String ... objCmd.CommandText = "SELECT COUNT(ID) FROM TableName" n = objCmd.ExecuteScalar ... s = "There are " & n.ToString & " records in the database."