|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
How to create triggers for MSSQL?
Hi all,
I am new to this forum.. I need help in creating trigger for my database assignment. WOnder if anyone able to help? I have a library database, where i have a library member table and a Borrow-Return-Reservation table. My trigger fires whenever a borrower who is not a member in the database tries to perform a transaction or the number of materials borrowed for a particular member is more than 4 when rows are updated / inserted into my Borrow-Return-Reservation table. i have the syntax written in oracle SQL as such: ---------------------------------------------------------- create trigger chk before insert or update on table_name the table u keep the loan copy for each row declare copy number(5) begin select table_copy into copy from table_name where member_id = :new.member_id if(copy > 4) then raise_application_error(-20001','no more than 4 loans); end if end. ---------------------------------------------------------- However, i am using MSSQL whereby the above codes don't work. Appreciate if kind souls out there able to help mi solve my problem... Thanks in advance.. Best Regards Geraldin |
|
#2
|
|||
|
|||
|
just use Entreprise manager and when you edit your table, there is an Icon where you can add/edit triggers for your tables... just select the one for insert and add your code in.
you gonna need to replace a few thing like select Count(*)=@copy from table_name where member... |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > How to create triggers for MSSQL? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|