Solved

Insert Trigger

Posted on 2009-06-28
2
142 Views
Last Modified: 2012-05-07
I cannot touch the inline SQL in an application - but need to check a value on insert and perform a case statement against a value - basically an ISNULL around one of the values - how do I check a value on INSERT and if = X then...
0
Comment
Question by:tbaseflug
2 Comments
 
LVL 37

Accepted Solution

by:
momi_sabag earned 500 total points
ID: 24731786
create trigger my_Trigger on myTable for insert as

update t1
set colToChange= isnull(T2.colToChange, default_value)
from myTable t1
 join inserted t2 on t1.id = t2.id
0
 
LVL 14

Expert Comment

by:rob_farley
ID: 24733331
Depending on more details about the problem, I'd try to work it into a computed column instead of a trigger. Triggers can be notorious for locking, etc.

Are you saying that you want to change a particular value to record when a value was changed in a certain way, or just that you want a particular column to reflect the result of an ISNULL? If it's the latter, then a computed column is definitely the way to go.

Rob
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
execute a MS SQL script as a schedule SQL job 72 101
Date conversion in sql server 2012 6 26
SQL JOIN 6 39
SQL JOIN + SUBQUERY? 3 14
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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.

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

12 Experts available now in Live!

Get 1:1 Help Now