Reputation: 2651
I'm using RedGate SQL Data Generator to generate test data in SQL Server 2016. I have a table with a nullable DATETIME column called DELETE_TS. Another column, IUD_CODE, is CHAR(1). In production, that column is "D" when DELETE_TS is not null. Otherwise it is either "I" or "U" depending on some other logic.
To create "realistic" test data, I am trying to use a Python Script generator to create that logic. I'm currently using:
def main(config):
if DELETE_TS is None:
return "U"
else:
return "D"
But EVERY column comes up "D", even when DELETE_TS is null.
I haven't done much in Python before, so I'm sure it's something small I'm missing.
EDIT: Here is the DDL for the relevant columns in the table:
CREATE TABLE dbo.DIM_MERCHANT (
DELETE_TS DATETIME NULL,
IUD_CODE CHAR(1) NULL
)
Upvotes: 0
Views: 406
Reputation: 11
This works in python generator.
def main(config):
if DELETE_TS:
return "D"
else:
return "U"
Upvotes: 1