如何获取表变量的行数?
答案 0 :(得分:12)
如果您的意思是SQL Server表变量,它就像一个普通的表:
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;
答案 1 :(得分:1)
SELECT COUNT(*) OVER ( ) AS 'RowCount' FROM @yourTableVariable
适用于表变量!
答案 2 :(得分:0)
SELECT COUNT(*) FROM TABLE_NAME;