Red Gate forums :: View topic - Excluding columns
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Data Generator 2
SQL Data Generator 2 forum

Excluding columns

Search in SQL Data Generator 2 forum
Post new topic   Reply to topic
Jump to:  
Author Message
softworksgroup



Joined: 02 Apr 2012
Posts: 2

PostPosted: Tue Apr 03, 2012 12:19 am    Post subject: Excluding columns Reply with quote

I am a new user so I apologize if this question has an obvious answer.

In many of the tables I want to generate, the best value for a column is provided by a default defined in the database itself. How can I instruct the generator to ignore columns so that the database default will be applied. (The columns are defined NOT NULL so I cannot set the %Null attribute to 100%).

Thanks
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6588

PostPosted: Wed Apr 04, 2012 12:37 pm    Post subject: Reply with quote

Hi,

I have found a way to force some NULL values in using the Python generator, but I still can't get this to work for me. I think it's because SQL Data Generator uses BULK INSERT and you need some kind of format file to allow the bulk insert to jam in NULLs. Here is the Python script anyway in case you want to give it a try...
Code:
# shuffling and randomizing the results yourself
import System;
def main(config):
    # config["column_name"] is the column name
    # config["column_type"] is the column datatype
    # config["column_size"] is the column size
    # config["n_rows"] is the number of rows
    # config["seed"] is the current random seed
    from System import Array
    nullArray=Array.CreateInstance(System.DBNull,config["n_rows"])
    return (nullArray)
Back to top
View user's profile Send private message
cvillegas



Joined: 04 Apr 2012
Posts: 4

PostPosted: Thu Apr 05, 2012 3:00 pm    Post subject: ? Reply with quote

Is there an actual solution to this or an update that will be created with the ability to ignore columns in a table when generating data?
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6588

PostPosted: Thu Apr 05, 2012 5:16 pm    Post subject: Reply with quote

I've provided a solution that will insert NULL into the column, just need a SQL Server professional to get me around the limitation in bulk insert... If there is an answer to that it will work. If not I don't think SQL Data Generator can support it.
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6588

PostPosted: Thu Apr 05, 2012 5:26 pm    Post subject: Reply with quote

Ah, maybe not. I checked the source code, and it explicitly sets the Bulk Copy option "KeepNulls", so when SDG inserts null it overrides the default that would normally happen if you tried to insert a null value from a SQL query.

So I guess you have a feature request there. The code needs to be changed to make this work.
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6588

PostPosted: Thu Apr 05, 2012 6:15 pm    Post subject: Reply with quote

I have logged an enhancement request for this: SDG-988 - provided changing the KeepNulls property doesn't break other parts of the program, it should be possible to do.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group