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
全站熱搜