tags:

views:

70

answers:

3

How can I count the result of a table and pass into a Stored Procedure Variable?

DECLARE @totalrecs varchar
select count(id) from table1

I want the count record in the totalrecs variable.

+1  A: 
select @totalrecs= count(id) from table1
Mr. Brownstone
+3  A: 

like this

--will not count NULLS
select @totalrecs= count(id) from table1

--will count NULLS
select @totalrecs= count(*) from table1
SQLMenace
A: 

DECLARE @totalCount Int
Select @totalCount = count(*) 
From table1

Exec sp_DoSomething @Var = @totalCount
Leigh Shayler