日期:2014-05-17 浏览次数:20502 次
DECLARE @companyid VARCHAR (100)
SET @companyid='102,103,106,107,108'
SELECT * FROM oCompany WHERE CompanyID IN (@companyid)
DECLARE @companyid VARCHAR(100),@tsql varchar(6000)
SET @companyid='102,103,106,107,108'
select @tsql='SELECT * FROM oCompany WHERE CompanyID IN ('+@companyid+')'
exec(@tsql)
DECLARE @companyid VARCHAR (100)
SET @companyid='102,103,106,107,108'
SELECT *
FROM oCompany
WHERE charindex(CompanyID, @companyid ) > 0