|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
|
|
#1
|
|||
|
|||
|
SQL trigger
I'm new to using triggers and have an assignment to add triggers to my database tables. Of coarse the person who asked me to do this is out of town, so I'm hoping someone can help.
This is what needs to be saved as the trigger (called trg_jrn_Org.sql): if exists (select * from dbo.sysobjects where id = object_id('dbo.trg_jrn_Org') and OBJECTPROPERTY(id, 'IsTrigger') = 1) drop trigger dbo.trg_jrn_Org GO CREATE TRIGGER trg_jrn_Org ON dbo.Org FOR UPDATE AS BEGIN UPDATE org SET jrn_dt = GETDATE() , jrn_host_nm = HOST_NAME() , jrn_app_nm = APP_NAME() WHERE org_id IN (SELECT org_id FROM INSERTED) END GO So do I save this as a sep. file? or does all of this go directly into the trigger properties text area and replaces this: CREATE TRIGGER [TRIGGER NAME] ON [dbo].[Wkly_Rprt] FOR INSERT, UPDATE, DELETE AS or something else? |
|
#2
|
||||
|
||||
|
That's the whole code. It will create the trigger. Just go into iSQL and paste it and run it. You can see all your triggers by using Enterprise Manager. Right-click the table and choose All Tasks -> Triggers, then choose the type of trigger from the drop-down menu... there are only three: delete, insert, and update.
-Dave |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > SQL trigger |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|