遇到1个问题:
将字段中现在的字符串,替换成原字符串+YYY
例如:
 A字段   
 DDD
  VVV
  CCC替换成:
A字段
DDDYYY
VVVYYY
CCCYYY

解决方案 »

  1.   

    update t
    set a=a+'YYY'
      

  2.   

    查询用
    select [a]=a+'YYY' from T
      

  3.   

    遇到1个问题: 
    将字段中现在的字符串,替换成原字符串+YYY 
    例如: 
     A字段    
     DDD 
        VVV 
        CCC 替换成: 
    A字段 
    DDDYYY 
    VVVYYY 
    CCCYYY---
    update tb set a = a + 'YYY'
      

  4.   

    update 表名 set A=A+'YYY'
      

  5.   

    declare @t table (myyear int,mymonth int,myday int)
    insert into @t values(2005,1,1)
    insert into @t values(2003,2,5)
    insert into @t values(2006,5,5)
    insert into @t values(2006,1,2)
    update @t set myyear=Convert (varchar(10),myyear)+Convert(varchar(10),mymonth)+convert(varchar(10),myday )
    select * from  @t
      

  6.   

    update 表名 
    set A字段=A字段+'YYY' 
      

  7.   

    update   表名   set   A=A+'YYY'
      

  8.   

    update   表名   set   A=A+'YYY'提示数据类型 text 和 varchar 在 add 运算符中不兼容。因为 A字段 是text类型。
    这样的话怎么做???
      

  9.   

    update  表名 set A=convert(nvarchar,A)+'YYY' 
      

  10.   

    UPDATE  表名 
    SET A=CAST(A AS VARCHAR(MAX))+'YYY' 
      

  11.   

    CAST and CONVERT
    Explicitly converts an expression of one data type to another. CAST and CONVERT provide similar functionality.Syntax
    Using CAST:CAST ( expression AS data_type ) Using CONVERT:CONVERT ( data_type [ ( length ) ] , expression [ , style ] )
      

  12.   

    关于cast,convert数据类型转换,请查阅http://msdn2.microsoft.com/en-us/library/aa226054(SQL.80).aspx
      

  13.   

    update 表名 
    set A字段=A字段+'YYY'