• ashok.theagarajan (8/22/2016)


    from Database..MainTable A

    Right Outer Join Database..LookupTable B On A.Field like '%' + B.Field + '%'

    Right Outer Join TBL_ShiftDetails C On (convert(varchar(8), A.OpenTime, 108) >= C.ShiftStart and convert(varchar(8), A.OpenTime, 108) <= C.ShiftEnd)

    TheSQLGuru (8/22/2016)


    I will note that you are doing something that is not good, namely wrapping a column in a function in a WHERE or JOIN clause. Hopefully we can find a way to avoid that.

    Not only are functions used in the JOIN predicate, but the other JOIN is a LIKE with wildcards on both ends. :w00t:

    We're going to need the DDL and sample data. Also, is this already in production? Are you able to change the design of the table?