Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Make this a trigger?
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01060793
Message ID:
01061333
Views:
12
Thanks Sergey - as it turns out spent a few minutes reading the SQL Server Help (books online gizmo and came up with this...which seems to work just fine...

CREATE TRIGGER [tblPopulate_Monitoring_tiud1] ON dbo.resources
FOR INSERT, UPDATE
AS

DECLARE @pk_resource INT,
@resdesc VARCHAR(60)

IF UPDATE (resdesc)
BEGIN
UPDATE monitoring.dbo.tblApplicationList
SET ApplicationName = I.resdesc
FROM Inserted I, monitoring.dbo.tblApplicationList al
WHERE al.pk_appid = I.pk_resource
END


IF NOT Exists(select I.pk_resource from INSERTED I, monitoring.dbo.tblApplicationList al WHERE I.pk_resource = al.pk_appid)
BEGIN
SET @pk_resource = (SELECT I.pk_resource FROM INSERTED I)
SET @resdesc = (SELECT I.resdesc FROM INSERTED I)

INSERT INTO monitoring.dbo.tblApplicationList (pk_appid, ApplicationName) VALUES (@pk_resource, @resdesc)
END



>Try
>CREATE TRIGGER utr_resources_Insert
>ON resources
>FOR INSERT
>AS
>BEGIN
>	INSERT INTO Monitoring (pk_appid, ApplicationName)
>		SELECT pk_resource, resdesc FROM INSERTED
>			WHERE NOT EXISTS( SELECT * FROM Monitoring
>					WHERE Monitoring.pk_appid = INSERTED.pk_resource)
>
>END
>
>>I need to make this into a SQL Server 2000 trigger....
>>
>>SELECT pk_appid ;
>> FROM Monitoring ;
>> WHERE Monitoring.pk_appid = resources.pk_resource ;
>> INTO CURSOR (curMonitoring)
>>
>>SELECT Monitoring
>>IF RECCOUNT('curMonitoring') = 0
>> APPEND BLANK
>>ENDIF
>>
>>Replace Monitoring.pk_appid WITH resources.pk_resource ,;
>> Monitoring.ApplicationName WITH resources.resdesc
>>
>>
>>....the trigger obviously would to in the 'resources' table...anyone know what the trigger syntax should be?
>>
>>Thanks!
ICQ 10556 (ya), 254117
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform