something like:declare @Count intset rowcount 5SELECT news_ID, news_Title, news_Text, news_DateFROM tblNewsWHERE news_departmentID = @variableset @Count = @@Rowcountif @Count <= 3beginset rowcount 5 - @Count select from other tablesend set rowcount 0
this will return you 2 sets which you can join on the client.ordeclare @Count intSELECT @Count = count(*) FROM tblNewsWHERE news_departmentID = @variableif @Count<=3 beginexec('select * from (select top ' + convert(varchar(1), @Count) + ' news_ID, news_Title, news_Text, news_DateFROM tblNewsWHERE news_departmentID = ' + @variable + 'union allSELECT top ' + convert(varchar(1), 5-@Count) + ' news_ID, news_Title, news_Text, news_DateFROM tblNewsWHERE news_departmentID = ' + @variable + ') t'endor use sp_executesql instead of th exec to keep it parametrised. look up sp_executesql in BOLGo with the flow & have fun! Else fight the flow