关于select top 的问题,,,,求助! select top 2* from tableA如果tableA里只有一条纪录的话,这条语句,执行返回的是 1 条,而不是2条。我该怎么处理,如果返回的不是2条,就打印错误。总不能,select count(*) from (select top 2* from tableA) as tableB吧?谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 if(select count(*)from tb)>1 begin select top 2 * from tbendelsebegin select * from tb union all select * from tbend vchao13() 的方法不太好吧。总之,我这个top的件数是个变量,比如说,如果变量是2的话,只检索出一条,就debug.print错误。有没有办法。? select top 2 * from tableAif @@rowcount <> 2print 'error' if(select count(*)from tb)>1 begin select top 2 * from tbendelsebegin select * from tb union all select * from tbend if(select count(*)from tb)>1 begin select top 2 * from tbendelsebegin select * from tb union all select * from tbend >>>>>>>求一句SQL语句写法!!!!!!!! 怎样把EXECL数据倒入SQL SERVER?我急我想你们的答案 sql语句的查询问题 如何强制用户下线 登陆密码 修改带有分隔符列的数据? 如何将多个字段相同的记录全部查出来 问两个问题,非常急 PL/SQL如何定义和使用返回记录集的存储过程?(MountLion求教) 如何判断建立的临时表是否存在。 问个提取一张表中的记录问题 怎样来查询?
begin
select top 2 * from tb
end
else
begin
select * from tb
union all select * from tb
end
if @@rowcount <> 2
print 'error'
begin
select top 2 * from tb
end
else
begin
select * from tb
union all select * from tb
end
begin
select top 2 * from tb
end
else
begin
select * from tb
union all select * from tb
end