• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 184
  • Last Modified:

Need help with SQL Syntax

The following SQL was offerred as an unsolicited suggestion in another question I posted that was answered by someone else.

I am getting an error saying there is an unidentified column 'KT_Group_ID' on the last line of the statement.  I have stared at this for hours and cannot see the problem.  Can anyone help.

            UPDATE dbo.Tbl_KT_Items
               SET Observe_Status_Date = i.Observe_Status_Date
                  ,Observe_Percent_Complete = i.Observe_Percent_Complete
                 , Participate_Status_Date = i.Participate_Status_Date
                 , Participate_Percent_Complete = i.Participate_Percent_Complete
                 , Perform_Status_Date =i.Perform_Status_Date
                 , Perform_Percent_Complete = i.Perform_Percent_Complete
              FROM dbo.Tbl_KT_Items as KTI
             Inner Join (SELECT KTInst.Lookup_To_Tbl_KT_Groups_For_KT_Group
                               ,I.*
                          FROM Inserted as I
                         Inner Join dbo.Tbl_KT_Instances as KTInst
                            ON I.Lookup_To_Tbl_KT_Instances_For_Instance_ID = KTInst.ID
                           and KTInst.Lookup_To_Tbl_KT_Groups_For_KT_Group > 0
                       ) as I  
                on KTI.KT_Step_Number = I.kt_step_Number
               AND I.Lookup_To_Tbl_KT_Groups_For_KT_Group = KTI.KT_Group_ID
0
wsturdev
Asked:
wsturdev
1 Solution
 
derekkrommCommented:
the obvious question is are you 100% sure the column name is exactly KT_Group_ID and is in table Tbl_KT_Items?
0
 
fanopoeCommented:
I wonder if calling two join sources 'I' is impacting it?
>>>FROM Inserted as I
       Inner Join dbo.Tbl_KT_Instances as KTInst
       ON I.Lookup_To_Tbl_KT_Instances_For_Instance_ID = KTInst.ID
       and KTInst.Lookup_To_Tbl_KT_Groups_For_KT_Group > 0
>>>) as I  

Sometimes the errors point at the wrong thing.


hth
0
 
wsturdevAuthor Commented:
derekkromm -- that was it!!!

The author of the code was supposed to use a Declared variable from much farther up in the code.  There was no column called that in the specified table.  IT should have been a reference to @KT_Group_ID.

Thanks for triggering the brain cells!!!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now