为什么这个用In会错误?
select * from compinfo where departmentID in (SELECT SUBSTRING(CONVERT(varchar(2000), DptLimit), 2, LEN(CONVERT(varchar(2000), DptLimit)) - 2) AS DptLimit FROM UserInfo)
其中DepartmentID是int型.
提示错误是
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the varchar value '2,24,25,26,17,21,721 'to a column of data type int.
请问这个SQL语句应该怎么写呢?
------解决方案--------------------select * from compinfo ,UserInfo where charindex(convert(varchar(20),compinfo.departmentID) ,UserInfoDptLimit)> 0
=================================================
试试这个吧.
---------------------------
忘记了类型转换了.