| 
	
 | 
 Posted by Erland Sommarskog on 11/08/06 08:40 
Leanne (leannewu@connectretail.com.au) writes: 
> I am doing customization for microsoft POS. I manually added a record 
> to a table. The manage and maintenance of this table are done by POS, 
> and user can update the contents of this table. Is there any way I  can 
> lock this single row at database level to prevent it from being deleted 
> or changed by user? I am using SQL 2000 and vb.net. 
 
You could add a trigger: 
 
  CREATE TRIGGER tri ON tbl FOR UPDATE, DELETE AS 
  IF EXISTS (SELECT * FROM deleted WHERE key col = <yourrow>) 
  BEGIN 
     ROLLBACK TRANSACTION 
     RAISERROR('Hey, that is my row! Don''t mess with it!', 16, 1) 
     RETURN 
  END 
 
 
 
 
--  
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se 
 
Books Online for SQL Server 2005 at 
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx 
Books Online for SQL Server 2000 at 
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
 
  
Navigation:
[Reply to this message] 
 |