I have a database of 100 brands of cars. I need to increase the size of the base 1000 times, that is, up to 100,000 marks. This is necessary for testing and therefore these 100 brands can be simply repeated 1000 times. I use "java" and "SQL Server 2005".

How can this be done?

  • the problem is not obvious - Valera Kvip
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

3 answers 3

insert into Marks(a,b,c) select Aa,Ab,Ac from Marks A, Marks B 

If there are 100 entries in the table, then such a request will make 100 * 100 already. 10,000 entries. Add in from another label or subquery, which gives 10 records and get your 100k. You can add values ​​to the fields, for example row_number() or rand() to vary the values.

     DECLARE @t TABLE( randnum float ) DECLARE @cnt INT; SET @cnt = 0 WHILE @cnt <=1000 BEGIN SET @cnt = @cnt + 1 INSERT INTO @t SELECT RAND( (DATEPART(mm, GETDATE()) * 100000 ) + (DATEPART(ss, GETDATE()) * 1000 ) + DATEPART(ms, GETDATE()) ) END SELECT randnum, COUNT(*) FROM @t GROUP BY randnum 

    from here: https://stackoverflow.com/a/6371562/6679190

    Similarly, if you wish, you can select not random values, but a table with 100 marks.

      While 1 = 1

       INSERT INTO 'your table' VALUES (NEW ID(), NEW ID(), NEW ID(), DatePart(millisecond,GetDate())