-- 声明变量 DECLARE @userID INT, @userName VARCHAR(50) SELECT ID INTO #temp FROM As_User WHILE EXISTS(SELECT ID FROM #temp) BEGIN -- 取值 SELECT top 1 @userID= ID FROM #temp; -- 操作 print(@userID) -- 删除本次操作数据 DELETE FROM #temp WHERE ID=@userID; END -- 是否删除临时表 -- DROP TABLE #temp