declare @aa varchar(100)
set @aa = 'aaaa,sadfas,asdfgasdf,asdfasd,asdf,asfasdf'
while charindex(',',@aa) > 0
begin
Select left(@aa,charindex(',',@aa)-1)
Set @aa = right(@aa,len(@aa) - charindex(',',@aa))
end
Select @aa
可以参考这个把ID的数一个一个取出来再去UPDATE,
但这样的效率好像没有用WHERE IDIN('''+@ID+''')高

解决方案 »

  1.   

    update [table] set [check]=1 where @id like '%,'+cast(id as varchar(10))+',%'
      

  2.   

    declare @id varchar(100)
    update [table] set [check]=1 where @id like '%,'+cast(id as varchar(10))+',%'
      

  3.   

    不知道你所谓的:
    我不想用类似这样的办法:
    @id char(10)declare @sql char(100)
    select @SQL = "update table set check=1 where id in(" + @id + ")"exec @sql是想有何指,你是想指你传递的参数不想用char类型,还是存储过程中的处理不想用上面的方法?
      

  4.   

    如果这些id是比较固定的,可以考虑把这些id保存到一张表中,然就就可以用in来判断了