Make SQL Select same row multiple times

后端 未结 11 2193
南方客
南方客 2020-12-11 16:02

I need to test my mail server. How can I make a Select statement that selects say ID=5469 a thousand times.

11条回答
  •  忘掉有多难
    2020-12-11 17:01

    If I get your meaning then a very simple way is to cross join on a derived query on a table with more than 1000 rows in it and put a top 1000 on that. This would duplicate your results 1000 times.

    EDIT: As an example (This is MSSQL, I don't know if Access is much different)

    SELECT
        MyTable.*
    FROM
        MyTable
    CROSS JOIN
    (
        SELECT TOP 1000
            *
        FROM
            sysobjects
    ) [BigTable]
    WHERE
        MyTable.ID = 1234
    

提交回复
热议问题