存储过程选择变量

ios*_*nyc 8 sql sql-server stored-procedures

如何计算表的结果并传入存储过程变量?

DECLARE @totalrecs varchar
select count(id) from table1
Run Code Online (Sandbox Code Playgroud)

我想要totalrecs变量中的计数记录.

SQL*_*ace 14

像这样

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

--will count NULLS
select @totalrecs= count(*) from table1
Run Code Online (Sandbox Code Playgroud)