Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

generate random data for one table

Status
Not open for further replies.

tirf

Programmer
Sep 22, 2008
59
US
I am trying to generate some random data for one table

this table; its parents are already populated

can I generate random data for this table through data generation plan (database project) and get its foreign keys from the parent tables?

Thanks
 
Something like:

Code:
DECLARE @RandomForeignKey INT
SELECT @RandomForeignKey = PrimaryKeyColumn FROM (SELECT TOP 1 PrimaryKeyColumn FROM ParentTable ORDER BY NEWID()) x
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top