Interview Questions

Using query analyzer, name 3 ways you can get an accurate count of the number of records in a table.

.NET Database ,COM interop,and .NET deployment questions and answers


(Continued from previous question...)

Using query analyzer, name 3 ways you can get an accurate count of the number of records in a table.

Answer1.
a. Select count(*) from table1
b. SELECT object_name(id) ,rowcnt FROM sysindexes WHERE indid IN (1,0) AND OBJECTPROPERTY(id, ‘IsUserTable’) = 1
c. exec sp_table_validation @table = ‘authors’

Answer2.
SELECT count( * ) as totalrecords FROM employee
This will display total records under the name totalrecords in the table employee

use COUNT_BIG
Returns the number of items in a group.

@@ROWCOUNT
Returns the number of rows affected by the last statement.
Use this statement after an SQL select * statement, to retrieve the total number of rows in the table

(Continued on next question...)

Other Interview Questions