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
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...