如何计算表的结果并传入存储过程变量?
DECLARE @totalrecs varchar
select count(id) from table1
我想在totalrecs变量中记录计数记录。
答案 0 :(得分:14)
--will not count NULLS
select @totalrecs= count(id) from table1
--will count NULLS
select @totalrecs= count(*) from table1
答案 1 :(得分:2)
DECLARE @totalCount Int
Select @totalCount = count(*)
From table1
Exec sp_DoSomething @Var = @totalCount
答案 2 :(得分:1)
select @totalrecs= count(id) from table1