I need to test my mail server. How can I make a Select statement that selects say ID=5469 a thousand times.
You can use the UNION ALL statement.
Try something like:
SELECT * FROM tablename WHERE ID = 5469
UNION ALL
SELECT * FROM tablename WHERE ID = 5469
You'd have to repeat the SELECT statement a bunch of times but you could write a bit of VB code in Access to create a dynamic SQL statement and then execute it. Not pretty but it should work.
The easy way is to create a table with 1000 rows. Let's call it BigTable
. Then you would query for the data you want and join it with the big table, like this:
SELECT MyTable.*
FROM MyTable, BigTable
WHERE MyTable.ID = 5469
create table #tmp1 (id int, fld varchar(max)) insert into #tmp1 (id, fld) values (1,'hello!'),(2,'world'),(3,'nice day!')
select * from #tmp1 go
select * from #tmp1 where id=3 go 1000
drop table #tmp1
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.
easy way...
This exists only one row into the DB
sku = 52 , description = Skullcandy Inkd Green ,price = 50,00
Try to relate another table in which has no constraint key to the main table
Original Query
SELECT Prod_SKU , Prod_Descr , Prod_Price FROM dbo.TB_Prod WHERE Prod_SKU = N'52'
The Functional Query ...adding a not related table called 'dbo.TB_Labels'
SELECT TOP ('times') Prod_SKU , Prod_Descr , Prod_Price FROM dbo.TB_Prod,dbo.TB_Labels WHERE Prod_SKU = N'52'
If your are doing this in sql Server
declare @cnt int
set @cnt = 0
while @cnt < 1000
begin
select '12345'
set @cnt = @cnt + 1
end
select '12345'
can be any expression