CREATE TABLE [identigy].[patron](
[ID] [bigint] NOT NULL,
[DISID] [nvarchar](20) NOT NULL,
[PKID] [nvarchar](20) NULL,
[DISHID] [nvarchar](20) NULL,
[FIRSTNAME] [nvarchar](250) NULL,
[LASTNAME] [nvarchar](250) NULL,
[CLASSIFICATION] [nvarchar](250) NULL,
[FLAGS] [nvarchar](500) NULL,
[SHIFTS] [nvarchar](50) NULL,
[ACTION] [nvarchar](10) NULL,
[ACTIVE] [bit] NOT NULL CONSTRAINT [DEFAULT_Identigy_Patron_Active] DEFAULT ((1))
,[DISIDnullbuster] AS (CASE WHEN [DISID] IS NULL THEN CAST(ID AS VARCHAR(20)) ELSE DISID END)
,[PKIDnullbuster] AS (CASE WHEN [PKID] IS NULL THEN CAST(ID AS VARCHAR(20)) ELSE PKID END)
,CONSTRAINT [PK_Identigy_Patron] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (IGNORE_DUP_KEY = ON) ON [PRIMARY]
,CONSTRAINT [UX_Identigy_Patron_DISID] UNIQUE ( [DISIDnullbuster] ASC ) WITH (IGNORE_DUP_KEY = ON) ON [PRIMARY]
,CONSTRAINT [UX_Identigy_Patron_PKID] UNIQUE ( [PKIDnullbuster] ASC ) WITH (IGNORE_DUP_KEY = ON) ON [PRIMARY]
) ON [PRIMARY]
GO