Reputation: 2249
how do i get the rowcount of table variables?
Upvotes: 7
Views: 20174
Reputation: 2762
SELECT COUNT(*) OVER ( ) AS 'RowCount' FROM @yourTableVariable
works perfect for table variables!
Upvotes: 1
Reputation: 5192
If you mean SQL Server table variables, it's just like a normal table:
DECLARE @Foo TABLE
(
foo int
);
insert into @Foo values (1);
insert into @Foo values (1);
insert into @Foo values (1);
insert into @Foo values (1);
select COUNT(*) from @Foo;
Upvotes: 13