SQL Data Generator 4

Help for older versions available.

Conforming to unique constraints in SQL Data Generator

Tables that have columns with unique constraints and indexes may require special attention when generating data using SQL Data Generator.

For example, the following table contains a unique index on the TicketTypeCode column. SQL Data Generator may generate non-unique and NULL data for this column by default, violating the constraint:

  1. CREATE TABLE [dbo].[TicketType](
  2. [TicketTypeID] [int] IDENTITY(1,1) NOT NULL,
  3. [TicketTypeCode] [nvarchar](10) NOT NULL,
  4. [TicketTypeName] [nvarchar](50) NOT NULL,
  5. [RowVersion] [timestamp] NOT NULL,
  6.  
  7. CONSTRAINT [PK_TicketType] PRIMARY KEY CLUSTERED
  8. (
  9. [TicketTypeID] ASC
  10. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  11. ) ON [PRIMARY]
  12.  
  13. CREATE UNIQUE NONCLUSTERED INDEX [IX_TicketType] ON [dbo].[TicketType]
  14. (
  15. [TicketTypeCode] ASC
  16. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

In order for data in the above example to be generated, change the setting for the column [TicketTypeCode] in SQL Data Generator to an Account Number or 5 Digit ID, and make sure the "Set unique" option is selected. This will allow the data to be generated.


Didn't find what you were looking for?