update table1 set data=(select top 1 line from table2)
或者
update table1 set data=t2.line
from table1 t1,table2 t2 where t1.???=t2.??? ........

解决方案 »

  1.   

    你想怎样合并?table2.line和table1.data的字段类型是什么?
      

  2.   

    data 和 line都是字符传。比如:
    table2中有很多记录(line)
    id line
    1  asdf
    2  zxcv
    3  lkjha我希望最终例如:
    update table1 where id=指定记录 set data=( .....不知道怎么写....)
    最终:
    table1中那条记录的data 字段的内容是类似"asdf zxcv lkjha"的形式。也就是说要把table2 中的所有内容放到一个字符串中。
      

  3.   

    --这样的更新无法用一个语句实现--你可以这样处理
    declare @s varchar(8000)
    set @s=''
    select @s=@s+' '+line from table2
    update table1 set data=stuff(@s,1,1,'') where id=指定记录
      

  4.   

    --或者写个自定义函数
    create function f_str()returns varchar(8000)
    as
    begin
    declare @s varchar(8000)
    set @s=''
    select @s=@s+' '+line from table2
    return(stuff(@s,1,1,''))
    end
    go--调用函数实现更新
    update table1 set data=dbo.f_str() where id=指定记录
      

  5.   

    (select line from table2)是个结果集.当然不能赋值了