/ Published in: SQL
If we don't have a primary key and unable to create a foreign key
- 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)
You need to login to post a comment.