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

Generate Date with Python Script based on Server Assigned FK

I have a table Customer that has a CustomerID column. I currently have it set to Server Assigned. The Customer table also has a CreatedDate column, to indicate when a Customer was first created. This CreatedDate column is being randomized by date offset to within a range of date values.

I have another table, CustomerComment, with CustomerID as a foreign key relating to the CustomerID of the Customer table. I have a CommentDate in the CustomerComment table, to store when the comment was made, and I want to date offset it, but I want to do a range of values that can only start on or after the same date as the CreatedDate in the Customer table that corresponds to the same row.

CustomerID __ CreatedDate

CommentID __ CustomerID __ CommentDate

In other words, I want to refer to a column in another table that is linked by foreign key, and base my column's data on that. I have tried the Python script method, as that seems the only solution, but I keep receiving this exception: "Cannot reference data in a server assigned column [dbo].[CustomerComment].[CustomerID]"

My script looks just like the code from the example I grabbed from this other forum post about a similar issue:

Any help for this issue in particular, or for a solution to the general problem of needing to keep dates programmatically "logical" with respect to their parent tables?

Sign In or Register to comment.