I need to test my mail server. How can I make a Select statement that selects say ID=5469 a thousand times.
Here's a way of using a recursive common table expression to generate some empty rows, then to cross join them back onto your desired row:
declare @myData table (val int) ;
insert @myData values (666),(888),(777) --some dummy data
;with cte as
(
select 100 as a
union all
select a-1 from cte where a>0
--generate 100 rows, the max recursion depth
)
,someRows as
(
select top 1000 0 a from cte,cte x1,cte x2
--xjoin the hundred rows a few times
--to generate 1030301 rows, then select top n rows
)
select m.* from @myData m,someRows where m.val=666
substitute @myData for your real table, and alter the final predicate to suit.