SQL Server Performance

Restriction in Insert

Discussion in 'General Developer Questions' started by daipayan, Mar 11, 2009.

  1. daipayan New Member

    I have table, where if data is inserted in two attempts, after that, noone can neither insert or update the data in the following table,e.g.
    First am just inserting the following value in MyTable:
    --------------------------------------
    ID Student Course Marks
    --------------------------------------
    1 Andy ASM <NULL>
    2 Bob ASM <NULL>
    3 Andy OB <NULL>
    4 Bob OB <NULL>
    ---------------------------------------
    Here, you can see, Marks column left blank, and other column being filled up, on next attempt, marks will be inserted only once and if someone wants to update or delete it, the TRIGGER should restrict it.
    How can this be done??
  2. dhamu294 New Member

    create an INSTEAD OF Update trigger and have your logic similar to below
    if exists
    ( select 'x' from <table> where mark is null)
    begin
    print 'u dont have permision for this '
    end
    else
    begin
    < your update logic here. >
    end

Share This Page