문제

I'm interested in learning some new skills and have been reading up about bulk inserts. So I have created two tables in sql server 2008 1) Client 2)ClientDetails, the set designs are as below:

Client Table

ClientID | ClientName | DetailsID

ClientDetails Table

DetailsID | Address1 | Address2 | Country

My question is, i want to create about 10,000 rows of data to try and use a bulk insert, how could i create 10,000 rows of random test data to use a bulk insert into the two tables?

도움이 되었습니까?

해결책

There are a number of data generator sites available online. The one I have used most is http://www.generatedata.com/#generator. This will allow you to create a lot of realistic data, including things like name, phone, address and country, and export them in a variety of formats. It only allows a max of 5,000 records, but just run it twice and you've got your 10,000.

다른 팁

Late answer but can be useful to the thread visitors

Have you tried ApexSQL Generate? It enables generating test data from a CSV or a TXT file (a very well-known and commonly used data sources). You can insert all the data from your CSV/TXT file – you’ll just need to set the delimiter, column index, etc. first.

You can download this tool for free and play with it – it allegedly can quickly generate millions of rows.

To learn more about the tool, you may visit https://www.apexsql.com/sql_tools_generate.aspx

There's one very nice feature you can use:

select 'test' as x, getdate() as gd
go 10

You can write one insert and and make it "GO 1000". Ofcourse, for your need, you'd probably have to write a batch that would randomize the data, but still it's better than, let's say, a loop.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top