Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 15th, 2004, 05:16 AM
Registered User
 
Join Date: Dec 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL trigger, rollback , update, limits

Hi,
How can I update a table's OTHER columns while using rollback or raiserror to show that one specific column can't be changed?
eg;
in student table, I just want to update/delete/insert the student's FamilyName, and LastName, If update his StudentID, a trigger rollback will active and StudentID wont be updated while FamilyName and LastName have been changed.??

thanks

 
Old December 17th, 2004, 07:05 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

You could try and query the inserted and delete for what you want and use something like this and also can be use for update

Code:
Create table Test
(something char(1))
go
CREATE TRIGGER DeleteTrigger
ON Test
FOR DELETE
AS 
BEGIN

     Select * from deleted where something = 'A'
     if @@rowcount <> 0
          ROLLBACK TRAN
END

go

insert Test values ('A')
insert Test values ('B')
select * from Test

delete from Test where something = 'A'
select * from Test
delete from Test where something = 'B'
select * from Test
Jaime E. Maccou





Similar Threads
Thread Thread Starter Forum Replies Last Post
Rollback in trigger??? (explicit/autocommit) edvin SQL Server 2005 2 April 20th, 2008 05:28 PM
After Update Trigger debbiecoates SQL Server 2000 2 February 15th, 2008 04:55 AM
Create trigger on update bvpsekhar MySQL 23 May 4th, 2007 01:01 AM
Help With INSERT + UPDATE Trigger HenryE SQL Server 2000 1 December 11th, 2003 06:26 PM
Insert Update Trigger mstuart60 SQL Server 2000 10 September 30th, 2003 06:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.