2

I am trying to find out if there are mechanisms that will allow for data to only be inserted into tables and not deleted or updated in SQL Server?

Any help would be great, doing research at the moment and have become stuck.

Alex K.
  • 171,639
  • 30
  • 264
  • 288
HelloWoRlD
  • 129
  • 4
  • 12

3 Answers3

1

You can grant and revoke privileges in the tables:

    # only permission for insert and select
    GRANT SELECT, INSERT ON employees TO public;

    # or revoke other permissions
    REVOKE UPDATE,DELETE  ON mytable FROM public;

You can control permissions for user(s)/public

M.Hassan
  • 10,282
  • 5
  • 65
  • 84
0

Presumably, you mean insertions and selects.

If so, you can create instead of triggers on the table for deletes and updates. These triggers would simply return errors or warnings and not change the table.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
0

I personally wouldn't create trigger on each table to prevent INSERT and just disallow UPDATE and DELETE rights for all users.

Evaldas Buinauskas
  • 13,739
  • 11
  • 55
  • 107