还没明白楼主要求,不过要截取字符串,只有用substring()啊!=========================================================
我的回复,尽可能为你分忧解难!
BLOG:blog.csdn.net/softj --欢迎光临,有更多信息等着你!
QQ群:8476022专研数据库          --大家进来聊一聊!
MSN:[email protected] --这不常用!
Mail:[email protected] --有什么问题可以和我来EMAIL!
=========================================================

解决方案 »

  1.   

    例如@phonetotal='13530214562,13530217562,13530215562,13930214562,13930214566,13930219562'
    这个是个text类型,也就是说它的长度大于8000.现在要截取字长,长度为120 如str1='13530217562,13530215562,13930214562,13930214566,...'text类型截取操作不行,能不能进行转化成varchar.请教.
      

  2.   

    --try
    substring(@phonetotal,1,120)
      

  3.   

    呵呵.....还是老问题
    declare @phonetotal text
    select @phonetotal='13530214562,13530217562,13530215562,13930214562,13930214566,13930219562'
    select substring(@phonetotal,1,24)
    服务器: 消息 2739,级别 16,状态 1,行 1
    对于局部变量,text、ntext 和 image 数据类型无效。
    ------------------------------------------------------有没新的解决方案
      

  4.   

    你的赋值
    @phonetotal='13530214562,13530217562,13530215562,13930214562,13930214566,13930219562'
    就不对
      

  5.   

    CREATE TABLE t1 (c2 text)INSERT t1 VALUES ('13530214562,13530217562,13530215562,13930214562,13930214566,13930219562'
    )
    declare @c2 varchar(100)
    select @c2=[c2] from t1
    select substring(@c2,1,24)
    drop table t1
      

  6.   

    --------------------- whbo(王红波(年轻人,要有所作为)) 这样直接赋值,会截去一部分字符,当c2长度大于8000时.
      

  7.   

    CREATE TABLE t1 (c2 text)INSERT t1 VALUES ('13530214562,13530217562,13530215562,13930214562,13930214566,13930219562'
    )
    declare @c2 varchar(100)
    select @c2=substring(c2,1,24) from t1
    print @c2
    drop table t1
    /*
    13530214562,13530217562,
    */