Triggers, where do they go? | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Triggers, where do they go?

using a trigger to limit duplicate inserts into a LOG table via a DTS package. I want it to skip the insert if theres already an existing entry. Field name is MdbId varchar(100)… So how do i write the trigger as well as where does it get stored? I can ses it in the sysobjects table.. but not in Enterprise Manager. Thanks
Dan
Here’s a slightly different suggestion – instead of a trigger, the usual method is just to insert the rows that do not match: insert into yourLogTable L1
select col_a, b, c from yourSourceData sd
where not exists ( select * from yourLogTable L2 where L2.key = sd.key )
You can check for existence of record by writing Procedures as well.
So no need for trigger here.
consider this if not exists(select columns from table where mobid=?)
begin
insert into table values()
end
else
begin
print ‘record already there’
end Through EM you can right click the table objects to see the triggers associated with it or by going to design of the table and in manage triggers.
That would work, if i wasnt working with a group of X%$#*. <img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ /> This is just patch work on an existing system that is soon going to be redesgned. (hopefully).
If you want to change the trigger, work either in Enterprise Manager or in Query Analyzer.<br /><br />Trigger definitions can be found in the only sensible place I can think of – since they are always attached to a table (before SQL 2005, that is): look up the table, then check the options you have there.<br /><br />But if you have to ask this, then I would think you need to do some studying in BOL before even thinking of changing a trigger definition …[<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]
To answer your question about where to find the trigger definition, here is how in enterprise manager. Right click on the table and to to All Tasks > Manage Triggers. John
Also, incase you were curious. Here is a way to see the trigger definition in query analyzer. –To see the trigger name if you forget
sp_depends ‘table_name’ –To see the trigger definition
sp_helptext ‘trigger_name’ John
Or in Query Analyzer, select the table from the object tree, open the subitem for triggers, select the trigger, right-click and select one of the options to script the object.
]]>