菜鸟一问 求一语句

晓轩 2006-07-07 09:41:13
我想得到查询结果辑还想得到统计的行数。必须在一条SQL里写。不用存储过程。拜谢了。。。。。
...全文
200 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
fcuandy 2006-07-07
  • 打赏
  • 举报
回复
或者用UNION加成行.
或者用
select *,行数=(select count(*) from [table]) from [table]
fcuandy 2006-07-07
  • 打赏
  • 举报
回复
select a.*,b.c from [table] a
inner join
(select count(*) c from [table]) b
on 1=1
liangpei2008 2006-07-07
  • 打赏
  • 举报
回复
--这样?
Declare @n int
Select @n=count(*) From tb
Select @n
晓轩 2006-07-07
  • 打赏
  • 举报
回复
楼上大哥,不要存储过程。。。只要sql语句,请指教。。。在线等
Yang_ 2006-07-07
  • 打赏
  • 举报
回复
示例性质:

create proc test
@cn int output
as
select * from tablename where ....
select @cn=@@count
go

--调用
declare @cn int
exec test @cn output
wsh236 2006-07-07
  • 打赏
  • 举报
回复
count()
晓轩 2006-07-07
  • 打赏
  • 举报
回复
谢谢大家。楼上正解 跪谢了

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧