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
 Other SQL Server Topics (2005)
 sql trigger creation

Author  Topic 

jason45678
Starting Member

1 Post

Posted - 2009-10-29 : 18:34:20
I am new at this. The following statement generates error msg 208 when I execute from studio:

USE [xxxx]
GO
/****** Object: Trigger [dbo].[updateActiveServiceCount] Script Date: 10/29/2009 16:00:15 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: vaughn
-- Create date:
-- Description: update active service count in users table
-- =============================================
ALTER TRIGGER [dbo].[updateActiveServiceCount]
ON [dbo].[Users_Info]
AFTER INSERT,UPDATE
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

Update Users Set Active_Service_Count = A.cntUser From
(Select Count(*) cntUser,Individual_Number From Client_Searches_Individuals as csi
where csi.Individual_Number = [dbo].[Users_Info].id Group by id,Individual_Number) A
Where id=a.Individual_Number

END

The idea is to update the users table with a record count from client_searches_individuals when the table users_info is updated.

   

- Advertisement -