列 content varchar(8000)
从  content中取出有5-10位的数字的记录,并返回一个整数,该整数表示模式第一次在字符串中出现的起始位置

解决方案 »

  1.   

    select cast(content as int) as content from tb where len(content) > 5
      

  2.   

    从  content中取出有5-10位的数字的记录,比如qq号码
      

  3.   

    SELECT PATINDEX('%123%',content)
    FROM table模式:123
    位置:PATINDEX返回值另:你的描述不是很清楚
      

  4.   

    select Col, patindex('%' + replicate('[0-9]', 10) + '%', Col) as [Index]
    from (select 'adsa1234567890asdfafds1234567890ads' as Col
          union select 'adsfasd'
          union select '1234567890') a
    where patindex('%' + replicate('[0-9]', 10) + '%', Col) > 0
    /*
    Col                                 Index       
    ----------------------------------- ----------- 
    1234567890                          1
    adsa1234567890asdfafds1234567890ads 5*/
      

  5.   

    select cast(substring(content,5,6) as int) as xx
    from tablename
      

  6.   

    create table tb(content varchar(8000))  
    insert into  tb select '31234567890'
    insert into  tb select '0123456789'  
    insert into  tb select '012345678935343534' 
    insert into  tb select 'df2345678935sdfsad'select cast(substring(content,5,6) as int) as xx
    from tbdrop table tb
    这个可以大于10位以上的啊
      

  7.   

    select substring(col, 5, 5) from tablename