//*****有两种方法 //one select count(*) as RowCount from tbale1 where id=条件;//two create proc proc_system_filter ( @SQLEx varchar(1000), @RowCount int output ) as begin
if(@SQLEx is not null and rtrim(ltrim(@SQLEx))<>'' and @SQLEx<>N'') begin SELECT @ROWCOUNT=COUNT(*) FROM TABLE1 WHERE (1>0) ID=@SQLEX; endend
//two create proc proc_system_filter ( @SQLEx varchar(1000), @RowCount int output ) as begin declate @strSQL varchar(2000); set @strSQL='SELECT ''+@ROWCOUNT+''=COUNT(*) FROM TABLE1 WHERE (1>0)'; if(@SQLEx is not null and rtrim(ltrim(@SQLEx))<>'' and @SQLEx<>N'') begin set @strsql=@strSQL+@SQLEx; end exec(@strSQL); end
select count(*) as '记录条数' from (select * from 表) A 可以的
Select Count(*) As '记录个数'
From
(对一个表执行了select语句) A
//one
select count(*) as RowCount from tbale1 where id=条件;//two
create proc proc_system_filter
(
@SQLEx varchar(1000),
@RowCount int output
)
as
begin
if(@SQLEx is not null and rtrim(ltrim(@SQLEx))<>'' and @SQLEx<>N'')
begin
SELECT @ROWCOUNT=COUNT(*) FROM TABLE1 WHERE (1>0) ID=@SQLEX;
endend
create proc proc_system_filter
(
@SQLEx varchar(1000),
@RowCount int output
)
as
begin
declate @strSQL varchar(2000);
set @strSQL='SELECT ''+@ROWCOUNT+''=COUNT(*) FROM TABLE1 WHERE (1>0)';
if(@SQLEx is not null and rtrim(ltrim(@SQLEx))<>'' and @SQLEx<>N'')
begin
set @strsql=@strSQL+@SQLEx; end
exec(@strSQL);
end
可以的
您好,我们是“2006中国杰出数据库工程师评选”活动组委会。
您的帖子已经被我们转载到本次评选官方网站的“专家在线答疑”区。
http://www.bestdba.cn/match_discussion.aspx在那里,进入本次评选复选的90位数据库工程师将与您展开积极的互动。
一方面,他们会为您的问题提供满意的答案,
另一方面,也邀请您为他们投上宝贵的选票。2006-7-8 ~ 2006-7-25日,每天我们将从当天参与"有奖投票"的网友
中抽取3名幸运者,赠送由IBM提供的精美礼品一份!此外,您还可以在“专家在线答疑”区提出新的问题并参与讨论。您的帖子位于:
http://www.bestdba.cn/match_discussion3.aspx?pointid=193&pointid2=1&pointid3=5&pcount=stc非常感谢您对本次活动的支持!
--------------------------------------------------------------
注册日期: Jul,2006
发贴数: 0 :), 假设你的sql为 <sql statement> then select count(*) from (<sql statement>)