SQL Async Multiple Queries Combine Results — Maximum Results (Top XYZ)

后端 未结 4 1558
忘了有多久
忘了有多久 2021-01-26 08:47

I have a search function set up, where I run multiple queries simultaneously. The top 1000 results of each query are written to a table. (These run async--I am just leaving out

4条回答
  •  悲哀的现实
    2021-01-26 08:58

    The following SQL limits the number of rows to 4 from any subsequent query

    SET ROWCOUNT 4

    SET @Rows = @@ROWCOUNT

    Get the number of rows form the preceeding select

    so something like

    SELECT TOP etc...

    SET @Rows = @@ROWCOUNT

    SET ROWCOUNT 1000 - @Rows

    Will probably error if @row goes below zero

    but you an trap this with IF and goto PROC_LABLE

提交回复
热议问题