Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

The mystery of the missing SQL triggers

Posted on 2001-08-21
2
Medium Priority
?
231 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 400 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

927 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