当前表
EmployeeID CompanyID EmployeeCode EmployeeName
1001 C001 11919 ABC
1002 C001 10974 PQR
1003 C001 11890 XYZ
1004 C001 11621 LMN
像这样查询...
DECLARE @Empid VARCHAR(MAX)
SELECT @Empid= COALESCE(@Empid +',','')+''''+EmployeeID+'''' FROM cmsEmployee WHERE employeeCode IN('11919','10974','11890','11621' )
print @Empid
SELECT * FROM cmsEmployee WHERE EmployeeID IN( @Empid)
这不起作用,为什么?