/ Published in: SQL
If we don't have a primary key and unable to create a foreign key
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
IF we don't have a primary key and unable to create a foreign key we need to wirte a function which validate the other table and call this in check constraint. SIMPLY: Calling function under Check constraint. alter table YourTable add constraint chk_CheckFunction check (dbo.CheckFunction() = 1) create function dbo.CheckFunction() returns int as begin return (select 1) end