GTSubset - CreateIndex script failed when NULL data exists an a non-NULL column

Document ID : KB000096878
Last Modified Date : 17/05/2018
Show Technical Document Details
Issue:
Consider the following table in MS SQL Server:
 
CREATE TABLE [dbo].[short_table](
    [short_column] [varchar](max) NULL,
    [idx] [int] NOT NULL,
    [bad_data_here] [varchar](max) NOT NULL,
 CONSTRAINT [PK_short_table] PRIMARY KEY CLUSTERED
(
    [idx] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

If, somehow "NULL" data ended up in the "bad_data_here" column, the output CreateIndex.sql script generated by GTSubet would encounter errors on any row with the incorrectly NULL data.
Resolution:
GTSubset, the output scripts and Database engine are all functioning as designed.

GTSubset generated the scripts as it was designed to with the data provided without modifying the source data.

The Database engine generated errors accordingly when the source data did not meet the defined constraints (NULL data in a non-NULLABLE column).

The resolution here would be to fix the source data and ensure that there is no NULL data in a non-NULLABLE column.