Return to Snippet

Revision: 37032
at December 2, 2010 23:06 by hairajeshk


Initial Code
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

Initial URL


Initial Description
If we don't have a primary key and unable to create a foreign key

Initial Title
Check Constraint - Calling function under Check constraint

Initial Tags


Initial Language
SQL