Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Help with trigger

Author  Topic 

ferrethouse
Constraint Violating Yak Guru

352 Posts

Posted - 2010-01-29 : 00:42:07
When I have this trigger in place the inserts seem to fail (not sure how to debug it). Here is the trigger code...


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TRIGGER [dbo].[LearningPath_CertificateURL_Trigger]
ON [dbo].[LearningPaths]

FOR INSERT
AS
BEGIN

SET NOCOUNT ON;

DECLARE @CertURL varchar(500)

SET @CertURL = (select CertificateURL from Inserted)

if @CertURL is null
UPDATE LearningPath SET CertificateURL = '_certificate.swf' where LearningPathID = Inserted.LearningPathID

END

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-01-29 : 01:06:10
[code]
UPDATE a
SET CertificateURL = '_certificate.swf'
FROM LearningPath a inner join inserted i
on a.LearningPathID = i.LearningPathID
where i.CertificateURL is null
[/code]




KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -