字符串是:'10,11,110'我要转换成10,11,110
是在存储过程执行的
因为是操作testID not in('10,11,110'),testID是int类型,所以要testID not in(10,11,110)

解决方案 »

  1.   


    declare @str varchar(30)
    set @str='10,11,110'exec(' where testID not in('+@str+')')
      

  2.   


    if object_id('tb')is not null drop table tb
    go 
    create table tb(id int identity,testid int)
    insert tb select
    12 union all select
    10 union all select
    110 
    declare @str varchar(30)
    set @str='10,11,110'exec(' select * from tb where testID not in('+@str+')')
     
    id          testid
    ----------- -----------
    1           12(1 行受影响)
      

  3.   

    declare @temp varchar(255)
    declare @str varchar(255)
    set @str='10,11,110'
    set @temp='select ......where testid not in('+@str+')'
    select @temp
      

  4.   

    where charindex(','+ltrim(testID)+',',','+@变量+',')=0也可以这样.