SQL Server - Generate persons test data

Quickly generate some persons data using popular AdventureWorks database sample. If you need to quickly test some functionality you would probably require some data for your tables. This script is one of the “generate test data” series. Really simply generating first and last name combinations using CROSS JOIN statement.

You can use local AdventureWorks database or any accessible one using linked server…

TIP: Use TOP statement in first line to control number of rows generated

SELECT TOP 1000 p1.FirstName, p2.LastName
FROM (
	SELECT 
		FirstName, LastName
	FROM AdventureWorks.Person.Person
) AS p1
CROSS JOIN
(
	SELECT 
		FirstName, LastName
	FROM AdventureWorks.Person.Person
) AS p2

Results

Script results screen:

Results screen

Script results detailed description:

Column nameData typeDescription
FirstNamenvarchar(50)First name picked from table Person.Person in sample database AdventureWorks.
LastNamenvarchar(50)Last name picked from table Person.Person in sample database AdventureWorks.

Leave a Reply

Your email address will not be published. Required fields are marked *