?
Solved

More help with triggers

Posted on 2005-04-27
2
Medium Priority
?
274 Views
Last Modified: 2010-03-19
I have a trigger which updateds a linked server.  This trigger is working when I only need to update on strPatientid.  I would like to modify the trigger to update records in the database where the familyid matches.

Here is what I have so far.

Create Trigger Consent_Date
ON tblPatient
FOR UPDATE
AS
IF UPDATE(dtmEligExpires)
BEGIN
    SET XACT_ABORT ON
    UPDATE    DEN
    SET              CONSENTDATE = inserted.dtmEligExpires
    FROM BCSQL.dentrix.dbo.DDB_PAT_BASE AS DEN
    INNER JOIN inserted ON DEN.CHART = inserted.strPatientid
    INNER JOIN(select FAMILYID, count(*) from DEN having count(*) > 1 where inserted.strPatientid = DEN.CHART) as NameCount)
    on DEN.familyid = NameCount.familyid
    WHERE DEN.chart = inserted.strPatientid
    where Den.familyid = NewCount.familyid
   
END


Thanks for your help.
0
Comment
Question by:running32
2 Comments
 
LVL 28

Accepted Solution

by:
rafrancisco earned 2000 total points
ID: 13876869
Try this one:

Create Trigger Consent_Date
ON tblPatient
FOR UPDATE
AS
IF UPDATE(dtmEligExpires)
BEGIN
    SET XACT_ABORT ON
    UPDATE    DEN
    SET  CONSENTDATE = inserted.dtmEligExpires
    FROM BCSQL.dentrix.dbo.DDB_PAT_BASE AS DEN
    INNER JOIN inserted ON DEN.CHART = inserted.strPatientid
    WHERE DEN.FamilyID = (SELECT FamilyID FROM BCSQL.dentrix.dbo.DDB_PAT_BASE DEN2
                          WHERE DEN2.Chart = inserted.strPatiendID
                          GROUP BY FamilyID HAVING COUNT(*) > 1)
END
0
 

Author Comment

by:running32
ID: 13876952
Perfect.  Thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
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.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Suggested Courses

829 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