select count(*) from table where col like '%X%';?

解决方案 »

  1.   

    提供個思路declare @strpartcode varchar(8000)
    declare @cnt int
    set @strpartcode=''
    set @cnt=0select @strpartcode=@strpartcode+yourField from yourtablewhile charindex('A',@strpartcode)>0   --把'A'換成你的特定字串/字符
     begin
    set @cnt=@cnt+1
                    set @strpartcode=RIGHT(@strpartcode,len(@strPartcode)-charindex('A',@strpartcode))  --把'A'換成你的特定字串/字符  END 
    print @cnt   --@cnt即為特定字符/字串出現的次數