sql server - How can I have a foreign key that points to a computed column? -


i have table:

create table [dbo].[question] (     [questionid]       int              identity (1, 1) not null,     [text]             nvarchar (4000)  null,     [questionuid]      uniqueidentifier default (newid()) not null, ); 

i create foreign key linking questionuid in other table admintestquestion questionuid in question table.

the referenced table '[dbo].[question]' contains no primary or candidate keys match referencing column list in foreign key. if referenced column computed column, should persisted.

any advice appreciated.

first of all: not computed column - it's regular column default constraint...

for column in table used foreign key reference, must either primary key of table, or has have unique index on it.

so here, need add unique index on column

create unique index uix_questionuid on dbo.question(questionuid) 

and should able reference foreign key.


Comments

Popular posts from this blog

Python Kivy ListView: How to delete selected ListItemButton? -

asp.net mvc 4 - A specified Include path is not valid. The EntityType '' does not declare a navigation property with the name '' -