SQL Server 2000 - block records being deleted or PK being changed?

Soldato
Joined
8 Feb 2004
Posts
3,822
Location
London
I'm running SQL Server 2000.

Is there a way of stopping a record being deleted, or the primary key value being altered?

I'm guessing it's either a table / column setting, or I need to use pre-triggers somehow.

TIA
 
You can't specifically stop a record being deleted, however you can place constraints on certain fields in a table which will prevent a deletion if certain conditions are met, i.e. a child record still exists in a related table.

The best way to prevent a primary key being altered is by marking it as an identity seed in design view.
If for whatever reason you can't do this, because maybe you're using composite keys, you can set permissions on the individual fields to allow/block access to reading/writing them, although this isn't something I've done, so google is probably your friend :)
 
You could prevent a given user from deleting records by setting the appropriate permissions against the table for that user. You can also set column permissions, as Spunkey says. Take a look in Enterprise Manager by right clicking on the table, choosing Properties, then clicking on Permissions.
 
Back
Top Bottom