sql server - Constraint based on relationship of two tables? -


basically want allow edit/update in table when column in table b null. table , table b reference same primary key id. like;

-- allow table updated when table b column null  update tablea set blah = @a, foo = @b tablea inner join tableb on tablea.id = tableb.id tableb.column null 

is there way use constraint on table a?

create trigger tr_instead_update_table_a on tablea instead of update begin   set nocount on;     if not exists(select 1                  deleted d inner join tableb b                 on d.pk_column = b.pk_column                 b.columnname null)     begin         raiserror('invalid update',16,1)         return;     end    -- update statement here   end 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -