What are the challenges you face when working across database platforms? Take the survey
Options

Datetime / Offset from column - request

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, 2006-2016 + 2019-now // Friend of Red Gate)

Comments

  • Options
    Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    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.
  • Options
    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
Sign In or Register to comment.