拼接出sql语句

1.列子:sql server中更新scores表中的Sname等于从students表中Sname

select * from scores;

 

《拼接出sql语句》

 

select * from students;

《拼接出sql语句》

更新scores表中的Sname等于从students表中Sname

select 'update scores set SName='''+t.Sname+''' where SId='+s.SId +';'  updateSqwl
from(
        select a.SId,a.Sname 
        from students a
      
)t
inner join scoreS s on t.SId=s.SID;

《拼接出sql语句》

赋值出来执行就达到效果了

select * from scores;

《拼接出sql语句》

2018.08.13 我同事跟我说的

 

    原文作者:SQL
    原文地址: https://blog.csdn.net/qq_23591001/article/details/81700942
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞