-3

I have the following code:

 SELECT *
 From [CMM].[dbo].[schedule] S
   join [CMM].[dbo].[schedule_activity] SA 
        ON S.[schedule_id = SA.schedule_id
   join [CMM].[dbo].[schedule_activity_part] SAP 
    ON SA.schedule_activity_id = SAP.schedule_activity_id
   join [CMM].[dbo].[activity] A 
    ON SA.activity_id = A.activity_id
 Where S.schedule_id = '5106'

And I am getting this error:

Msg 4145, Level 15, State 1, Line 6
An expression of non-boolean type specified in a context where a condition is expected, near 'SAP'.

4
  • 2
    is it because you're missing a bracket?
    – Matthew
    Jun 26, 2013 at 14:38
  • 1
    You might want to add some syntactic sugar and specitfy the joins as INNER JOINinstead of just Join. Won't make any difference, but it's arguably easier to read.
    – jpw
    Jun 26, 2013 at 14:41
  • it is a very simple syntax issue (missing close bracket on S.[schedule_id <--- Jun 26, 2013 at 15:42
  • 5
    This question appears to be off-topic because you missed a bracket in your query.
    – Taryn
    Jun 26, 2013 at 15:42

1 Answer 1

3

The fourth row is wrong or at least has a typo: ON S.[schedule_id = SA.schedule_id There's an [ too much

3
  • 1
    or a ] too little...
    – Hart CO
    Jun 26, 2013 at 14:41
  • Indeed. I can't really see any reason for the brackets in this query at all though, the identifiers doesn't seem to require bracketing.
    – jpw
    Jun 26, 2013 at 14:42
  • agreed, die brackets die!
    – Hart CO
    Jun 26, 2013 at 14:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.