读书人

怎么SQL返回查询的记录数

发布时间: 2012-02-05 12:07:14 作者: rapoo

如何SQL返回查询的记录数?
如何SQL返回查询的记录数?

[解决办法]
select @@rowcount
[解决办法]
在语句后+
select * from ta
print @@rowcount
[解决办法]
select count(*) from
(
查询语句
)
[解决办法]
select rowcnt from sysindexes where
id in (select id from sysobjects where name = 'tablename ')
and status=0

最快的方法!
[解决办法]
@@rowcount
[解决办法]
@@ROWCOUNT
返回受上一语句影响的行数。

语法
@@ROWCOUNT

返回类型
integer

注释
任何不返回行的语句将这一变量设置为 0 ,如 IF 语句。


[解决办法]
select count(*) from tbName
where ...

读书人网 >SQL Server

热点推荐