Apr 16, 2010 #1 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
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
Apr 16, 2010 #2 RiverGuy Programmer Jul 18, 2002 5,011 US Something like: Code: DECLARE @RandomForeignKey INT SELECT @RandomForeignKey = PrimaryKeyColumn FROM (SELECT TOP 1 PrimaryKeyColumn FROM ParentTable ORDER BY NEWID()) x Upvote 0 Downvote
Something like: Code: DECLARE @RandomForeignKey INT SELECT @RandomForeignKey = PrimaryKeyColumn FROM (SELECT TOP 1 PrimaryKeyColumn FROM ParentTable ORDER BY NEWID()) x