update A set SQLcode =isnull((select SQLcode from B where fID='110'),'') 
where ID='001'

解决方案 »

  1.   

    或者
    update A set SQLcode =B.SQLcode
    from B 
    where A.ID='001' and B.fID='110'
      

  2.   

    update A
    set SQLcode = 'select * from B where fID=''110'''
    where ID = 001
      

  3.   

    update table1 set [SQLcode] = 'select * from B where fID=' + char(xxx) + '110' +char(xxx)xxx的值要查一下
      

  4.   

    CREATE procedure usd_Update_SQLcode
    as
    declare @tmp varchar(8000)
    select @tmp=B表中正确的字段 from B where fID='110'
    update A set SQLcode=@tmp
    go
      

  5.   

    你要把 select * from B where fID='110' 里的内容更新到SQLcode字段这句话很含糊,不可能把几个字段更新到一个字段里。
    我猜你的意思会不会是:
    CREATE procedure usd_Update_SQLcode
    as
    declare @tmp varchar(8000)
    select @tmp=B表中正确的字段 from B where fID='110'
    update A set SQLcode=@tmp
    go
      

  6.   

    晕,我和小李铅笔刀一样看错了^_^
    update A set SQLcode =isnull('select SQLcode from B where fID=''110''','') 
    where ID='001'
      

  7.   

    update A set SQLcode =(select B表中与之匹配的字段如b.sqlcode from B where fID='110') 
    where ID='001'
      

  8.   

    也可以是
    update A set SQLcode =isnull('select B表中与之匹配的字段如b.sqlcode from B where fID='110'','') 
    where ID='001'
      

  9.   

    *********************************
    好多人看错题了吧?
    我是要把常字符量写入A表的SQLcode字段.本来以为
    update A
    set SQLcode = 'select * from B where fID=''110'''
    where ID = 001
    不行,原来不是,是行的.那我再问问,如果我要用存储过程,而且常字符串“select * from B where fID='110'”要作为参数传进去,谁可以帮我再写写,想多说一句,写完存储过程希望可以再谢谢执行时怎么把该参数传进去!我试过,但是因为那个单引号的问题而报错.谁可以帮帮忙,谢谢了!
    ##########################################
      

  10.   

    create procedure usd_UpdateSQLString @SQLString varchar(8000)
    as
    update A set SQLcode=@SQLString
    GO执行时:
    exec usd_UpdateSQLString 'update A set SQLcode =isnull(''select SQLcode from B where fID=''110'''','''') 
    where ID=''001'''
      

  11.   

    funsuzhou(羡米奇)(努力ing,成为专家中!) 
    你的好象不行哦,照你的原文的话,就把SQLcode更新为: update A set SQLcode =isnull(''select SQLcode from B where fID=''110'''','''') 
    where ID=''001'''            这个了!!这样吧:现在"select SQLcode from B where fID='110'"
    我要用存储过程把A表中数据段 SQLcode 的值更新为字符串常量"select SQLcode from B where fID='110'",且"select SQLcode from B where fID='110'"作为参数传给存储过程,这个字符串常量的内容无法更改,即没办法在它里面加单引号之类的.那现在又该如何呢??
    有没有人可以帮忙??