close
declare@id int,@stuff varchar(20)declare@tmp table(
  id int notnull, stuff varchar(20)primarykey(id))insert@tmp
select id, stuff from mastertable
where condition1 > condition2

selecttop1@id=id,@stuff=stuff from@tmp

while(@@rowcount>0)beginprint@stuff
  deletefrom@tmp where id=@id
  selecttop1@id=id,@stuff=stuff from@tmp
end

http://stackoverflow.com/questions/18827729/tsql-perform-code-for-each-row-of-an-select
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 amychang2014 的頭像
    amychang2014

    工作需要筆記

    amychang2014 發表在 痞客邦 留言(0) 人氣()