sql server - can I use a variable for the integer expression in a left sql function -
i have following query:
select top 2500 * table left join table b on a.employee_id = b.employee_id left(a.employee_rc,6) in ( select employeeid, access accesslist employeeid = '#client.id#' ) the sub select in where clause can return 1 or several access values, ex:
- js1234 blkhsa
- js1234 hdf48r7
- js1234 bln6
in primary where clause need able change integer expression 6 5 or 4 or 7 depending on length of values returned in sub select. @ loss if right way go it. have tried using or statements slows down query.
try using exists instead:
select top 2500 * table left join table b on a.employee_id = b.employee_id exists (select 1 accesslist employeeid = '#client.id#' , a.employee_rc concat(employeeid, '%') ) ; i don't see how original query worked. subquery returning 2 columns , isn't allowed in sql in.
Comments
Post a Comment