| | |
Help required for UPDATE TRIGGER
Please support our MS SQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2009
Posts: 67
Reputation:
Solved Threads: 0
Hi all,
I have created the Trigger for UPDATING to be invoked when Returnedon column is updated using the following code snnipet.
Now I want To perform this Updation only if the RETURNEDON column is null. If the ReturnedOn column consists of some other value then the Updation of records should not take place.
Can anyone help me out in performing this task?
Please help me out.
Thanks in advance!!
I have created the Trigger for UPDATING to be invoked when Returnedon column is updated using the following code snnipet.
MS SQL Syntax (Toggle Plain Text)
CREATE TRIGGER trg_ForUpdateOnBookIssuedDetails ON BOOKISSUEDDETAILS FOR UPDATE AS begin declare @Rows1 int,@Rows2 int IF(UPDATE(ReturnedOn)) begin begin tran UPDATE nur SET nur.NumberOfBooksIssued = nur.NumberOfBooksIssued -1 FROM NewUserRegister nur INNER JOIN INSERTED i ON i.IssuedTo=nur.UserName SET @Rows1 = @@RowCount UPDATE lbd SET Inventory = Inventory +1 FROM LIBRARYBOOKDETAILS lbd INNER JOIN inserted i ON lbd.BookID = i.BookId SET @Rows2 = @@rowcount IF @Rows1 * @rows2 >0 commit tran else begin raiserror('Error Updating the Database',16,-1) rollback tran end end end
Can anyone help me out in performing this task?
Please help me out.
Thanks in advance!!
![]() |
Similar Threads
- Help needed with UPDATE Trigger (MS SQL)
- create update trigger with parameters mssql (MS SQL)
- Logging Stored Procedure from Trigger (MS SQL)
- Body Text lost when sending hotmail (Web Browsers)
- mySQL TRIGGER problem (MySQL)
- hacktool.rootkit / backdoor.generic2.ppu issue (Viruses, Spyware and other Nasties)
Other Threads in the MS SQL Forum
- Previous Thread: Error in Trigger Using TRY CATCH AND IF ELSE
- Next Thread: Table Chaos
| Thread Tools | Search this Thread |





