我有一个包含 memberId 的表,但它们不会同时运行。
我必须如何遍历它们?
我有这个:
select mm.memberid, mm.aspnetuserid, mm.email
into #MemberIdsToDelete
from membership.members as mm
left join aspnet_membership as asp
on mm.aspnetuserid=asp.userid
left join trade.tradesmen as tr
on tr.memberid=mm.memberid
where asp.isapproved = 0 and tr.ImportDPN IS NOT NULL and tr.importDPN <> ''
order by mm.memberid
ALTER TABLE #MemberIdsToDelete ADD id int NOT NULL AUTO_INCREMENT
DECLARE @MaxRownum int
SET @MaxRownum = (SELECT MAX(id) FROM MemberIdsToDelete)
WHILE @Iter <= @MaxRownum
-- do things
SET @Iter = @Iter + 1
END
以上不正确,我在更改表行上明显出错:'AUTO_INCREMENT'附近的语法不正确