Solved

The mystery of the missing SQL triggers

Posted on 2001-08-21
2
218 Views
Last Modified: 2012-05-04
Hello experts

I am bumbling along trying to customise a software product (Maximo) which is using SQL Server 7 as the back end.

Sadly I've not worked with SQL before and I've had no training so I'm feeling my way a bit.

Today a bizarre thing happened (well it seems bizarre to me anyway).

I had set up several SQL triggers against one of my tables, and they had been working very well. And then someone mentioned they seemed to have stopped working.

I went to have a look at them (using Enterprise manager, which is the only way I know of maintaining them) and they have all DISAPPEARED.

Assuming I don't have a saboteur around the place, and that I am not on drugs (you'll just have to take my word for it) how could this have happened?

Does SQL automatically "manage" them, and store them elsewhere sometimes? Or is this a known SQL bug?

(Come to think of it, several weeks ago I thought this had happened to one of my test databases, but I thought "Nah - it couldn't be - I must be mistaken". And since the DB wasn't important I thought no more of it. But now it seems I WASN'T mistaken. I think they disappeared then also).

Any ideas please? My chances of building a robust system seem pretty slim at the moment.

Thanks

Iain MacRae
0
Comment
Question by:MacRae
2 Comments
 
LVL 18

Accepted Solution

by:
nigelrivett earned 100 total points
ID: 6409052
Triggers shouldn't disappear for no reason.

Usually it is because you have recrated the table.
When you drop a table all the associated triggers are also dropped so need to be recreated afterwards.

The easiest way to do this is to include the trigger script in the same file as the table creation script.
0
 

Author Comment

by:MacRae
ID: 6411813
Thanks Nigel

That was indeed the answer.

I had run a Maximo function which "reconfigures" the database (in my case changed the length of some data items in a table), but I hadn't realised that would cause my triggers to be lost.

Oh well, at least I know what is happening now, and I can be prepared for it next time.

Thanks for your help.

Regards

Iain Macrae
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now