0

Because of some testing I need to do I need to generate a database with 400000 records

I have done that with a simple

      "WHILE @RowCount <= @NumberRecords" etc..

My issue is how do I generate some sort of unique FirstName,Surname and Address.

Please dont point me to third party tool as I cannot use them .

Many thanks for your time

user9969
  • 15,632
  • 39
  • 107
  • 175
  • possible duplicate of [how to generate random data in SQL server](http://stackoverflow.com/questions/17977388/how-to-generate-random-data-in-sql-server) – Ashish Gaur Feb 10 '14 at 10:04
  • I hope this would help. Select char(CONVERT(int,26*rand())+65). 65 to 90 for the ascii A-Z. A function might help if you want consonant or vowel. – Elmer Feb 11 '14 at 02:47

1 Answers1

0

The standard way to select randomly from small table is to order by NEWID().

  SELECT TOP 400 *
  FROM Table1
  ORDER BY NEWID()

Read here more on efficient generation of random rows from large tables

Mudassir Hasan
  • 28,083
  • 20
  • 99
  • 133
  • hi thanks for your time but not use how do I generate unique surname or address from you answer.That is very genericc – user9969 Feb 10 '14 at 10:28