Sproc:USE [Bss]GO/****** Object: StoredProcedure [dbo].[spInsertLog] Script Date: 03/10/2009 04:12:06 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[spInsertLog]( @LogType int = 1, @Title varchar(128), @Note varchar(512), @Employee int, @Job int, @Permit int, @Customer int, @Professional int, @Document int)AS SET NOCOUNT OFF;IF ((SELECT [Enabled] FROM [BSS].[dbo].[LogType] WHERE (LogTypeId = @LogType)) = 1) BEGIN IF (ISNULL(@Title, '') = '') SELECT @Title = Title FROM [BSS].[dbo].[LogType] WHERE (LogTypeId = @LogType) INSERT INTO [Log](LogType, Title, Note, Employee, Job, Permit, Customer, Professional, [Document]) VALUES (@LogType,@Title,@Note,@Employee,@Job,@Permit,@Customer,@Professional,@Document) SELECT LogId, Title, Note, Employee, Job, Permit, Customer, Professional, [Document], CreationTime FROM [Log] WHERE (LogId = SCOPE_IDENTITY()) ENDELSE BEGIN (SELECT @Title = Title FROM [BSS].[dbo].[LogType] WHERE (LogTypeId = @LogType)) PRINT 'LogType ' + CAST(@LogType AS varchar(5)) + ' (' + @Title + ') is disabled, record was not added.' SELECT LogId = NULL, Title = NULL, Note = NULL, Employee = NULL, Job = NULL, Permit = NULL, Customer = NULL, Professional = NULL, [Document] = NULL, CreationTime = NULL ENDI want this SPROC to be the only way to add data to the log table so I decided to put it all in an instead of insert trigger, but I don't manage to, I get an error:Trigger:CREATE TRIGGER Log_INSERT ON [Log] INSTEAD OF INSERT AS BEGIN SET NOCOUNT OFF;DECLARE @LogType int, @Title varchar(128), @Note varchar(512), @Employee int, @Job int, @Permit int, @Customer int, @Professional int, @Document intSELECT @LogType = LogType, @Title = Title, @Note= Note, @Employee = Employee, @Job = Job, @Permit = Permit, @Customer = Customer, @Professional = Professional, @Document = DocumentFROM insertedIF ((SELECT [Enabled] FROM [BSS].[dbo].[LogType] WHERE (LogTypeId = @LogType)) = 1) BEGIN IF (ISNULL(@Title, '') = '') SELECT @Title = Title FROM [BSS].[dbo].[LogType] WHERE (LogTypeId = @LogType) INSERT INTO [Log](LogType, Title, Note, Employee, Job, Permit, Customer, Professional, [Document]) VALUES (@LogType,@Title,@Note,@Employee,@Job,@Permit,@Customer,@Professional,@Document) SELECT LogId, Title, Note, Employee, Job, Permit, Customer, Professional, [Document], CreationTime FROM [Log] WHERE (LogId = SCOPE_IDENTITY()) ENDELSE BEGIN (SELECT @Title = Title FROM [BSS].[dbo].[LogType] WHERE (LogTypeId = @LogType)) PRINT 'LogType ' + CAST(@LogType AS varchar(5)) + ' (' + @Title + ') is disabled, record was not added.' SELECT LogId = NULL, Title = NULL, Note = NULL, Employee = NULL, Job = NULL, Permit = NULL, Customer = NULL, Professional = NULL, [Document] = NULL, CreationTime = NULL ENDGOI get the following error:Msg 102, Level 15, State 1, Procedure Log_INSERT, Line 44Incorrect syntax near 'END'.
Shimmy