Contar los registros que me devuelve una consulta

Oyu
25 de Noviembre del 2005
Hola alguien podria decirme como saber cuantos registros me devolvio una consulta?
por ejemplo si hago un select * from empleado, como saber cuantos registros devolvio la consulta?, no se si exista una funcion que no sea count.
grcias ;)

JoSeTxU
25 de Noviembre del 2005
Supongo que es SQL Server, ya que no indicas contra qué SGBD trabajas.

------------ @@ROWCOUNT------------------
Returns the number of rows affected by the last statement.

Syntax
@@ROWCOUNT

Return Types
integer

Remarks
This variable is set to 0 by any statement that does not return rows, such as an IF statement.

Examples
This example executes UPDATE and uses @@ROWCOUNT to detect if any rows were changed.

UPDATE authors SET au_lname = 'Jones'
WHERE au_id = '999-888-7777'
IF @@ROWCOUNT = 0
print 'Warning: No rows were updated'