1. 程式人生 > >拼接出sql語句

拼接出sql語句

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

select * from scores;

select * from students;

更新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;

賦值出來執行就達到效果了

select * from scores;

2018.08.13 我同事跟我說的