Store Procedure Select into a variable

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.

Answers


like this

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

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

select @totalrecs= count(id) from table1

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

Exec sp_DoSomething @Var = @totalCount

Need Your Help

http://api.rubyonrails.org/ clone

ruby-on-rails documentation clone

I'd like to build a website very similar to http://api.rubyonrails.org/

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.