SQL Server Computed Column as Primary Key -
i've created table computed column primary key. table created fine.and here script..
set ansi_nulls on go set quoted_identifier on go set arithabort on go set ansi_padding on go create table [planning.a062].[rmallocation]( [id] [int] identity(100,1) not null, [rmallocatonid] ('rma_'+convert([nvarchar](100),[id])) persisted not null, [requsitionno] [nvarchar](100) null, [rmdemandid] [nvarchar](104) null, [hierarchyid] [nvarchar](102) null, [season] [nvarchar](50) null, [vendorsupplierno] [nvarchar](100) null, [year] [int] null, [month] [int] null, [week] [int] null, [day] [int] null, [plannedqty] [int] null, [confirmedqty] [int] null, [status] [int] null, [createdby] [int] null, [syncid] [nvarchar](100) null, [createdon] [datetime2](7) null, [updatedby] [int] null, [updatedon] [datetime2](7) null, [isactive] [bit] null, [recorddatetime] [datetime2](7) null, constraint [pk_rmallocation] primary key clustered ( [rmallocatonid] asc )with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on) on [primary] ) on [primary] go set ansi_padding off go the problem when change table (add/edit column ) using designer view,it gives me following error.

error
unable create index 'pk_rmallocation'. cannot define primary key constraint on nullable column in table 'rmallocation'. not create constraint. see previous errors. when use script modifications,it works. , have declared computed column not null. how happen??
this long comment. wrong designer. sql server quite clear in documentation computed columns can used primary keys (for instance, here).
my guess designer dropping constraints on table , adding them in. ends adding them in wrong order, primary key assigned before not null on computed column. have no idea if there work-around other obvious 1 of not using designer.
Comments
Post a Comment