Skip to main content

All Questions

Tagged with
1 vote
3 answers
86 views

Maintainable INSTEAD OF trigger with Identity columns

I want to add a trigger to my table to validate the data before allowing insert or update. For example, something like this: CREATE TABLE MyHorribleLegacyTable (i int IDENTITY, name char(100), ...
Scott's user avatar
  • 29
1 vote
0 answers
67 views

Trigger updating all instead of specific rows

I have a conditional update that I manually run from time to time. The conditions will always be on Loc and Item. The statement updates the [StockType] column for the rows that meet the conditions. ...
Sauce's user avatar
  • 45
0 votes
1 answer
98 views

Unwanted trigger fired though trigger's conditions do not satisfy

I am doing an assignment for triggers in SQL Server. The detailed assignment problem is: Faculty Head needs to be an instructor that belongs to his/her corresponding faculty and has degree either as &...
yoKuSugiTHo's user avatar
0 votes
0 answers
82 views

Catch Error in a SQL Server Logon Trigger

I have written a Logon trigger in a SQL Server to control logon authorization. ALTER TRIGGER [LOG_TRG_01] ON ALL SERVER WITH EXECUTE AS 'SA' FOR LOGON AS BEGIN if ORIGINAL_LOGIN() = 'sa' begin ...
altink's user avatar
  • 369
0 votes
1 answer
85 views

How to prevent an INSTEAD OF trigger from firing until another INSTEAD OF trigger has completed

I'm working on a project where two applications read/write the same tables. Neither application can be changed. One is written in Access, the other in .NET and will be replacing the Access application ...
Area51Resident's user avatar
0 votes
1 answer
47 views

How to get identity of another table record inside after insert trigger caused by a transaction for current scope and Session?

I have an AFTER INSERT trigger on a table named FileInformation. The trigger performs two updates on this table. It works fine when FileInformation is inserted into solely. But when a record is ...
gwt's user avatar
  • 2,423
0 votes
1 answer
77 views

Update a Column Value Whenever an Update is Run Against a Temporal Table

Say I have a temporal table that has a column IsReadyForStuff of datatype bit, and another column OrderDate. I would like to add a trigger to my temporal table that when OrderDate is updated also sets ...
Vaccano's user avatar
  • 82.7k
-2 votes
1 answer
62 views

Disallow column update based on existing value

I have the sample table below Student Current_Checkpoint John Smith 1 Jane Smith 3 To prevent erroneous updates or fat-finger en-masse updates, I want to enforce the following rule For the column ...
Yoav24's user avatar
  • 373
0 votes
2 answers
63 views

Spawn transaction from trigger

I'm struggling with triggers and indirect tables I need to mess with. Context: we have an old app whose backend we can't change but I have full access to the database. This app is inserting one row in ...
Alex's user avatar
  • 31
0 votes
0 answers
51 views

Old Script Backup Before Run DDL Commands

I have a trigger that follows DDL commands in SQL Server and writes them to the table and now I need to write the script before the alter is made to the table. Is such a thing possible? I can write ...
Atahan Çelik's user avatar
1 vote
1 answer
341 views

Create or alter trigger in other schema: There is already an object named 'myTrigger' in the database

I'm stuck with a weird problem with my new schema and can't find a solution. I successfully created a trigger using following statement: CREATE OR ALTER TRIGGER myTrigger ON [mySchema].[myTable] AFTER ...
diiN__________'s user avatar
-1 votes
2 answers
114 views

AFTER UPDATE TRIGGER to keep Total Credits up to date

In my University database, I have Student, Takes and Course tables: Student (ID, Name, DepartmentName, TotalCredits) Takes (StudentId, CourseId, SectionId, Semester, Year, Grade) Course (CourseId, ...
Hossein's user avatar
-2 votes
1 answer
93 views

SQL Server TRIGGER with JOIN

I am trying to write a TRIGGER that when certain conditions are met, the transaction must be rolled back. My script currently is as follows: CREATE TRIGGER trg_AfterInsert_On_InvNum ON InvNum AFTER ...
Gray Meiring's user avatar
0 votes
1 answer
105 views

How to roll back the changes if trigger failed

I have two table. The Invoices table and the Outputs table. I want to update table Outputs after the Invoices table has been updated. I want to roll back Invoices changes if Outputs update fails. ...
3PCO's user avatar
  • 13
0 votes
0 answers
49 views

How do I make one trigger fire but ignore the actions done by another trigger? [duplicate]

I have 2 triggers I need to make. The problem is that when a user inserts/updates a row, Trigger 1 fires, which updates the 3 columns defined below, which causes Trigger 2 to fire. But Trigger 2 is ...
TheMortiestMorty's user avatar

15 30 50 per page
1
2 3 4 5
64