title: Conversion failed when converting the varchar value '_1' to data type int
body: <p>Trying to run this query I wrote to return a list of files in a course, but running into this error that a conversion failed when converting the varchar value '_1' to data type int.</p>
  
  <pre><code>SELECT cm.course_id, cc.title title, cc.dtmodified dtmodified, MIN(xf.FILE_SIZE) file_size, MIN(crl.resource_id) resource_id, MIN(xu.FULL_PATH) full_path
    FROM BBLEARN.dbo.cms_resource_link crl
    INNER JOIN BBLEARN.dbo.course_contents cc ON cc.pk1 = crl.parent_pk1
    INNER JOIN BBLEARN.dbo.course_main cm ON cm.pk1 = crl.crsmain_pk1
    INNER JOIN BBLEARN.dbo.course_users cu ON cm.pk1 = cu.crsmain_pk1
    INNER JOIN BBLEARN.dbo.users u ON cu.users_pk1 = u.pk1
    INNER JOIN BBLEARN_CMS_DOC.dbo.XYF_FILES xf ON crl.resource_id = xf.ENTRY_ID + '_1'
    INNER JOIN BBLEARN_CMS_DOC.dbo.XYF_URLS xu ON xu.FILE_ID = xf.FILE_ID
    INNER JOIN BBLEARN_CMS_DOC.dbo.XYF_FILES xf2 ON xu.PARENT_ID = xf2.FILE_ID
    WHERE crl.parent_data_type='content'
    AND cu.role='P'
    AND crl.storage_type='PUBLIC'
    AND xf.FILE_TYPE_CODE='F'
    AND (LOWER(xu.FILE_NAME) LIKE N'%.mov%' or LOWER(xu.FILE_NAME) LIKE N'%.avi%' or LOWER(xu.FILE_NAME) LIKE N'%.wm%' or LOWER(xu.FILE_NAME) LIKE N'%.mp%' or LOWER(xu.FILE_NAME) LIKE N'%.rm%' or LOWER(xu.FILE_NAME) LIKE N'%.flv%' or LOWER(xu.FILE_NAME) LIKE N'%.amr%' or LOWER(xu.FILE_NAME) LIKE N'%.aif%' or LOWER(xu.FILE_NAME) LIKE N'%.aup%' or LOWER(xu.FILE_NAME) LIKE N'%.m4%' or LOWER(xu.FILE_NAME) LIKE N'%.wav%' or LOWER(xu.FILE_NAME) LIKE N'%.swf%')
    AND xu.FULL_PATH NOT LIKE '/internal/%'
    AND NOT EXISTS (
                  SELECT 1 FROM BBLEARN.dbo.cms_resource_link
                  WHERE crsmain_pk1 = crl.crsmain_pk1
                  AND parent_pk1 = crl.parent_pk1
                  AND parent_data_type='content'
                  AND resource_id = xf2.ENTRY_ID + '_1' )
    GROUP BY cm.course_id, cc.pk1, cc.title, cc.dtmodified ORDER BY 1;
  </code></pre>
  
  <p>Which shows up in line 7 and 21 I believe where there is the concatenation of <code>xf.ENTRY_ID + '_1'</code> and <code>xf2.ENTRY_ID + '_1'</code></p>