MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old February 20th, 2004, 10:49 AM
geri geri is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 1 geri User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old March 1st, 2004, 06:04 PM
sypher sypher is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Montreal
Posts: 92 sypher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 10 sec
Reputation Power: 5
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...

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > How to create triggers for MSSQL?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway