0

I have stored procedure like this

create store procedure onetimeprocessing  
as
begin
declare @input_data (id int,title varchar(400),topic varchar(400))
insert into @input_data
select id,title,topic from dB

I just want to count number of records in the virtual table @input_data

How should I get the count.Please help me Thanks in Advance

gbn
  • 408,740
  • 77
  • 567
  • 659
Linnet
  • 101
  • 1
  • 3
  • 7

3 Answers3

2
select count(*) from @input_data

or after the insert

select @@rowcount
Dumitrescu Bogdan
  • 6,842
  • 2
  • 22
  • 31
1

Why not just have this?

create store procedure onetimeprocessing  
as
begin
select COUNT(*) as TheCount from dB

Edit

I'm having difficulty understanding why other folk would suggest to load @inputdata first, then count from that. or return an extra result set with @@ROWCOUNT...

gbn
  • 408,740
  • 77
  • 567
  • 659
1

Its available in @@ROWCOUNT:

declare @input_data table (id int,title varchar(400),topic varchar(400))
insert into @input_data select ....

SELECT @@ROWCOUNT
Alex K.
  • 165,803
  • 30
  • 257
  • 277