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
- Aug 11 Tue 2015 16:13
-
SQL select foreach
請先 登入 以發表留言。