Hot answers tagged trigger
I am assuming you are trying to implement some basic replication using a trigger. As long as your process remains fairly simple, this should work OK. However, I would advise you to read up on (i.e. google) why executing stored procedures from triggers is not a good idea, and also about SQL's built in transactional replication feature. Here is a practical ...
My guess is that your trigger has a "insert into ... select * from myTable" kind of structure, and now it's broken because there's one more column in the table. Change your trigger so that it lists the columns instead of using *.
IF @@ROWCOUNT > 0 BEGIN ROLLBACK TRANSACTION; END ELSE BEGIN ... continue ... END
I'd put this in a comment but I want to give pictures. My guess is that you are hitting the little green arrow, or DEBUG button Instead of the red exclamation point, or RUN button. It's a fairly common mistake. FYI you can also hit Ctrl-E to "execute" the script or Alt-F5 to "debug" it. The TSQL debugger requires elevated rights (sysadmin if I ...
Here's a very quick example that will create a user blat given an existing login blat in all new databases created (this won't work for attach/restore). You could extend this to adding them to roles, granting permissions, even building the list based off of some query from sys.server_principals in master, sys.database_principals in another database, or your ...
"Is it possible to do so? The trigger will insert some rows into a unique table that exists only on the slave." yes, you can A lot of warehousing architectures are based on the slave only. The title of your question is wrong. Change replica DB with SLAVE ONLY
Based on your comment, the trigger has multiple lines. You need a BEGIN...END block as follows: USE mcet DELIMITER $$ DROP TRIGGER IF EXISTS tg_student_details_insert; CREATE TRIGGER tg_student_details_insert BEFORE INSERT ON student_details FOR EACH ROW BEGIN SET NEW.created_date = NOW(); SET NEW.dobw = date_to_words(NEW.dob); END; DELIMITER ; ...
Only top voted, non community-wiki answers of a minimum length are eligible