Click here to Skip to main content
14,427,655 members
   

Database

 
GeneralRe: The following Query is taking too long to execute Pin
Eddy Vluggen1-Jun-18 1:10
professionalEddy Vluggen1-Jun-18 1:10 
QuestionGraph Database vs Dimensional Pin
DADom24-May-18 22:32
MemberDADom24-May-18 22:32 
AnswerRe: Graph Database vs Dimensional Pin
Eddy Vluggen26-May-18 3:45
professionalEddy Vluggen26-May-18 3:45 
GeneralRe: Graph Database vs Dimensional Pin
John 1356415428-Jun-18 10:07
MemberJohn 1356415428-Jun-18 10:07 
GeneralRe: Graph Database vs Dimensional Pin
Eddy Vluggen28-Jun-18 10:19
professionalEddy Vluggen28-Jun-18 10:19 
QuestionHow to create a insert trigger on just one table? Pin
Member23622-May-18 0:02
MemberMember23622-May-18 0:02 
QuestionRe: How to create a insert trigger on just one table? Pin
CHill6022-May-18 2:34
mveCHill6022-May-18 2:34 
AnswerRe: How to create a insert trigger on just one table? Pin
Richard Deeming22-May-18 3:30
communityengineerRichard Deeming22-May-18 3:30 
CREATE TRIGGER (Transact-SQL) | Microsoft Docs[^]
CREATE TRIGGER YourTriggerName
ON YourTableName
AFTER insert, update
As
BEGIN
    SET NOCOUNT ON;
    
    If UPDATE(FK)
    BEGIN
        UPDATE
            T
        SET
            RedundantDuplicateColumn = T2.Name
        FROM
            YourTable As T
            INNER JOIN inserted As I
            ON I.PK = T.PK
            LEFT JOIN YourOtherTable As T2
            ON T2.PK = T.FK
        ;
    END;
END

Replace the dummy table and column names with the real table and column names.

Remember that triggers will fire once per batch, not once per row. There could be multiple rows in the inserted table.

But as CHill60 said, duplicating the product name in both tables seems like a bad design. If you have the ID of the product, you can simply join to the product table to get the name on demand.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

AnswerRe: How to create a insert trigger on just one table? Pin
Mycroft Holmes22-May-18 15:09
MemberMycroft Holmes22-May-18 15:09 
GeneralRe: How to create a insert trigger on just one table? Pin
CHill6022-May-18 23:56
mveCHill6022-May-18 23:56 
GeneralRe: How to create a insert trigger on just one table? Pin
Mycroft Holmes23-May-18 14:20
MemberMycroft Holmes23-May-18 14:20 
GeneralRe: How to create a insert trigger on just one table? Pin
Member23623-May-18 0:04
MemberMember23623-May-18 0:04 
GeneralRe: How to create a insert trigger on just one table? Pin
Mycroft Holmes23-May-18 14:23
MemberMycroft Holmes23-May-18 14:23 
QuestionFOR XML PATH is not creating Child elements if they are coming with null values Pin
indian14316-May-18 13:39
Memberindian14316-May-18 13:39 
AnswerRe: FOR XML PATH is not creating Child elements if they are coming with null values Pin
CHill6022-May-18 2:32
mveCHill6022-May-18 2:32 
QuestionEquivalent of the following query without FOR XML PATH Pin
indian14314-May-18 13:03
Memberindian14314-May-18 13:03 
SuggestionRe: Equivalent of the following query without FOR XML PATH Pin
CHill6015-May-18 1:11
mveCHill6015-May-18 1:11 
GeneralRe: Equivalent of the following query without FOR XML PATH Pin
indian14315-May-18 7:39
Memberindian14315-May-18 7:39 
GeneralRe: Equivalent of the following query without FOR XML PATH Pin
CHill6015-May-18 23:11
mveCHill6015-May-18 23:11 
GeneralRe: Equivalent of the following query without FOR XML PATH Pin
indian14317-May-18 15:56
Memberindian14317-May-18 15:56 
RantLatest Oracle Connection method Pin
Mycroft Holmes6-May-18 15:56
MemberMycroft Holmes6-May-18 15:56 
GeneralRe: Latest Oracle Connection method Pin
Jörgen Andersson16-May-18 1:20
communityengineerJörgen Andersson16-May-18 1:20 
GeneralRe: Latest Oracle Connection method Pin
Mycroft Holmes16-May-18 1:27
MemberMycroft Holmes16-May-18 1:27 
GeneralRe: Latest Oracle Connection method Pin
Jörgen Andersson16-May-18 1:37
communityengineerJörgen Andersson16-May-18 1:37 
QuestionSQL 2016 Optimization ... Pin
Member 138060854-May-18 2:10
MemberMember 138060854-May-18 2:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.