Re: Inactive record
From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 04/27/05
- Previous message: Joe K.: "Add Database Role to Login Name"
- In reply to: Paul: "Inactive record"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Wed, 27 Apr 2005 23:55:17 +0200
On Wed, 27 Apr 2005 07:54:06 -0700, Paul wrote:
>Hi just wondering if there is a way to have one record in a table be read
>only, were an application can not remove it and have all other records act
>normally? I am currently handling this in .net code but would prefer to
>have it built into the table.
>thanks.
Hi Paul,
You can use a trigger:
CREATE TRIGGER DontTouchThisRow
ON MyTable AFTER UPDATE, DELETE
AS
IF EXISTS (SELECT *
FROM deleted
WHERE KeyCol = 1) -- Column to be protected
BEGIN
RAISERROR ('Row 1 may not be changed or removed', 16, 1)
ROLLBACK TRANSACTION
END
go
Best, Hugo
-- (Remove _NO_ and _SPAM_ to get my e-mail address)
- Previous message: Joe K.: "Add Database Role to Login Name"
- In reply to: Paul: "Inactive record"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]