CREATE TABLE #temp ( id INT IDENTITY(1, 1) PRIMARY KEY, mrp_no NVARCHAR(30), [status] VARCHAR(1) ) INSERT INTO #temp(mrp_no,status) SELECT 'AAA',1 DECLARE @id INT DECLARE @mrp_no NVARCHAR(30) DECLARE cur CURSOR FOR SELECT id,mrp_no FROM #temp --order by mrp_no OPEN cur FETCH NEXT FROM cur INTO @Id,@mrp_no WHILE @@FETCH_STATUS=0 BEGIN SELECT @mrp_no INSERT INTO #temp( mrp_no, status) SELECT 'BBB',2 FETCH NEXT FROM cur INTO @Id,@mrp_no END CLOSE cur DEALLOCATE cur select * from #temp --drop table #temp
在游标定义中的循环,插入游标生成表,直接死循环套娃了;
这让人很惆怅啊;
问题来自长沙的小伙伴