查找字段content中包含字符串str的行Declare @str  varchar(20)
set @str = '1.2,1.3,1.4'
SELECT [pro_id]
      ,[protype]
      ,[content]
      ,[diff]
      ,[chapter]
      ,[score]
  FROM [exam].[dbo].[shitiInfo]
where content like '%"+ @str +"%'

解决方案 »

  1.   

    SELECT [pro_id] 
          ,[protype] 
          ,[content] 
          ,[diff] 
          ,[chapter] 
          ,[score] 
      FROM [exam].[dbo].[shitiInfo] 
    where cast(content as varchar) like '%1.[2-4]%' 
      

  2.   

    SELECT [pro_id] 
          ,[protype] 
          ,[content] 
          ,[diff] 
          ,[chapter] 
          ,[score] 
      FROM [exam].[dbo].[shitiInfo] 
    where charindex(@str,content)>0 
      

  3.   

    SELECT [pro_id] 
          ,[protype] 
          ,[content] 
          ,[diff] 
          ,[chapter] 
          ,[score] 
      FROM [exam].[dbo].[shitiInfo] 
    where charindex(','+@str+',',','+content+',')>0 
      

  4.   

    CHARINDEX和PATINDEX函数常常用来在一段字符中搜索字符或者字符串