Datetime / Offset from column - request

The simplest way to populate your database with test data.

Moderators: JonathanWatts, David Atkinson, Anu Deshpande, Michelle Taylor, Lionel, Emma A

Datetime / Offset from column - request

Postby HugoKornelis » Fri Aug 02, 2013 10:33 pm

Hi all,

I'm trying to use SQL Data Generator (version 2.0.3.1) to generate extra data for the FactResellerSales table in the AdventureWorksDW2012 sample database. But in order to make it match the pattern of the rest, I find that some features are missing from Data Generator.

One of them is for generating the ShipDate. I have set OrderDate to be generated at random; ShipDate should always be a few days later (I'd like the delay to be random between 4 and 10 days). I can do that with the standard datetime generator, setting range to "Offset from column". However, this generator does not allow me to force the time part to always be zero.

(I could of course change the data type of the column to date, but I want the schema to remain equal to the original AdventureWorks. And there are probably other people too who can't just cahnge the data type in order to generate more realistic data.)

Is there a way to do this with the current product and I just fail to see it? And if not, is there a wishlist where I can add this?

Thanks in advance! :)
--
Hugo Kornelis
(SQL Server MVP and Friend of Red Gate)
HugoKornelis
 
Posts: 5
Joined: Wed Mar 25, 2009 10:48 am

Postby Brian Donahue » Mon Aug 05, 2013 10:54 am

Thanks for writing Hugo. The situation with SQL Data Generator is still that you can't derive a field of generated data from a field of generated data in a different column of the same table.

I usually suggest one of two solutions, none of which are particularly easy. One is to use the Ruby generator - that is a third-party addition which allows you to create data from Ruby scripts and supports manipulation of generated data so you can "derive" values from a different column.

https://www.simple-talk.com/content/art ... rticle=697

The second would be to use the Python generator on both columns and use a predictable set of numbers - for instance if you generate a random sequence of numbers in both columns based on the same "seed", you can just increment the value in the second column by +4.

There should be some examples on this forum about generating some random numbers in Python.
Brian Donahue
 
Posts: 6669
Joined: Mon Aug 23, 2004 10:48 am

Postby lvdancerdave » Thu Dec 12, 2013 8:15 pm

Hugo:

I'm new to the Red Gate Data Generator as well. While it may not be the best solution, you can edit project... -> Scripts and then choose to run a post data generation script that sets the time part to zero in the desired field.
David Burt
lvdancerdave
 
Posts: 2
Joined: Thu Dec 12, 2013 5:54 pm


Return to SQL Data Generator 2

Who is online

Users browsing this forum: No registered users and 0 guests