select TOP (all)

前端 未结 8 2054
再見小時候
再見小時候 2020-12-15 16:46
declare @t int
set @t = 10
if (o = \'mmm\') set @t = -1
select top(@t) * from table

What if I want generally it resulted with 10 rows, but rarely a

8条回答
  •  独厮守ぢ
    2020-12-15 17:29

    im not sure I understand your question.

    But if you sometimes want TOP and other times don't just use if / else construct:

    if (condition)
      'send TOP
      SELECT TOP 10 Blah FROM...
    else
      SELECT blah1, blah2 FROM...
    

提交回复
热议问题