现我要对一个字段更新 是变量加字段的形式, 
例: 
DECLARE @find varchar(30) 
set @find ='湖南' 
update table set name=@find +name 
现在的情况是变量放在前面的话,这样连接就不会成功; 
如果放在后面就可以成功连接,但结果是我需要放在前面 求一解决办法

解决方案 »

  1.   

    update table set name = rtrim(@find) + ltrim(name)
      

  2.   


    declare @name varchar(20),
            @find varchar(30)
     set @name=''
     set @find='湖南'
    update table set name=@name+frind
      

  3.   


    --参考:
    create table tb(col varchar(100))insert into tb select 'fdfa'
    insert into tb select 'fdf'
    insert into tb select 'df'DECLARE @find varchar(30) 
    set @find ='湖南' 
    exec('update tb set col = '''+@find +'''+col' )drop table tb
      

  4.   

    --参考:
    create table tb(col varchar(100))insert into tb select 'fdfa'
    insert into tb select 'fdf'
    insert into tb select 'df'update tb 
    set col=stuff(col,1,0,'湖南')select * from tb
    drop table tb