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.
Author |
Topic |
icw
Constraint Violating Yak Guru
378 Posts |
Posted - 2010-08-04 : 17:42:27
|
Hi I'm trying to crteate new trigger.Don't tell me off for not using Raiserror - (i'm looking in ti that and trying to learn about it)My more pressing problem here is I ge a message sayingMsg 4104, Level 16, State 1, Procedure SUMMARY_UPDATE, Line 15The multi-part identifier "calllog.repyear" could not be bound.Msg 4104, Level 16, State 1, Procedure SUMMARY_UPDATE, Line 15The multi-part identifier "calllog.repmonth" could not be bound.Here is the trigger===================USE [DB1]GO/****** Object: Trigger [dbo].[DURATION_UPDATE] Script Date: 08/04/2010 18:46:01 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO-- =============================================-- Author: <ICW>-- Create date: <04/08/10>-- Description: <Trigger to update the summary fields in calllog>-- =============================================create TRIGGER [dbo].[SUMMARY_UPDATE] ON [dbo].[Calllog]FOR INSERT, UPDATEASDeclare @CalliD Varchar(8)Declare @Year varchar(4)Declare @Month varchar(9)Select @callid=Callid FROM inserted WHEREisnull(calllog.repyear,'') > ''ANDisnull(calllog.repmonth,'') > ''IF @Callid IS NOT NULLBeginSelect @Year = calllog.repyearfrom calllogwhere callid = @callidSelect @Month = calllog.repMonthfrom calllogwhere callid = @callidUPDATE CallLogset calllog.repnumreps = t1.repsnumfrom calllog, (select count(callid) as "repsnum" from calllogwhere calllog.swerncode in (select swerncode from calllog where callid = @callid) andMonth (cast(faultstart as datetime)) = Datepart(Month,(@Month))ANDYear(cast(faultstart as datetime)) = Datepart(Year,(@year)))as "t1"Where calllog.CallID = @CallIDEND |
|
Sachin.Nand
2937 Posts |
Posted - 2010-08-05 : 02:40:19
|
quote: Originally posted by icw Hi I'm trying to crteate new trigger.Don't tell me off for not using Raiserror - (i'm looking in ti that and trying to learn about it)My more pressing problem here is I ge a message sayingMsg 4104, Level 16, State 1, Procedure SUMMARY_UPDATE, Line 15The multi-part identifier "calllog.repyear" could not be bound.Msg 4104, Level 16, State 1, Procedure SUMMARY_UPDATE, Line 15The multi-part identifier "calllog.repmonth" could not be bound.Here is the trigger===================USE [DB1]GO/****** Object: Trigger [dbo].[DURATION_UPDATE] Script Date: 08/04/2010 18:46:01 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO-- =============================================-- Author: <ICW>-- Create date: <04/08/10>-- Description: <Trigger to update the summary fields in calllog>-- =============================================create TRIGGER [dbo].[SUMMARY_UPDATE] ON [dbo].[Calllog]FOR INSERT, UPDATEASDeclare @CalliD Varchar(8)Declare @Year varchar(4)Declare @Month varchar(9)Select @callid=Callid FROM inserted WHEREisnull((select top 1 calllog.repyear from calllog),'') > ''ANDisnull((select top 1 calllog.repmonth from calllog),'') > ''IF @Callid IS NOT NULLBeginSelect @Year = calllog.repyearfrom calllogwhere callid = @callidSelect @Month = calllog.repMonthfrom calllogwhere callid = @callidUPDATE CallLogset calllog.repnumreps = t1.repsnumfrom calllog, (select count(callid) as "repsnum" from calllogwhere calllog.swerncode in (select swerncode from calllog where callid = @callid) andMonth (cast(faultstart as datetime)) = Datepart(Month,(@Month))ANDYear(cast(faultstart as datetime)) = Datepart(Year,(@year)))as "t1"Where calllog.CallID = @CallIDEND
Check the above part of the query marked in redLimitations live only in our minds. But if we use our imaginations, our possibilities become limitless. PBUH |
 |
|
Kristen
Test
22859 Posts |
Posted - 2010-08-05 : 03:23:30
|
""Select @callid=Callid FROM inserted WHEREisnull(calllog.repyear,'') > ''ANDisnull(calllog.repmonth,'') > '' You are referring to calllog but there is no table with that name in that statement. The actual table is inserted (yes, inserted is actually a version of calllog, but as fas as SQL is concerned at this point all it has is a table called inserted). Don;t forget to use RAISERROR   |
 |
|
|
|
|
|
|