subs
subs

Reputation: 2249

how do i get the rowcount of table variables?

how do i get the rowcount of table variables?

Upvotes: 7

Views: 20174

Answers (3)

Géza
Géza

Reputation: 2762

SELECT COUNT(*) OVER ( ) AS 'RowCount' FROM @yourTableVariable

works perfect for table variables!

Upvotes: 1

squawknull
squawknull

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

Mike Lewis
Mike Lewis

Reputation: 64147

SELECT COUNT(*) FROM TABLE_NAME;

Upvotes: -2

Related Questions