DECLARE @CName varchar(20)
DECLARE assay_cursor CURSOR
FOR
SELECT
[LP ].[LP Code]
FROM [LP ]
INNER JOIN [Assay Info] ON [LP ].[LP Code] = [Assay Info].[LP Code]
WHERE
((([LP ].Report) = 1))
GROUP BY
[LP ].[LP Code], [Assay Info].[Assay Date], [LP ].ZDescription
OPEN assay_cursor
FETCH NEXT FROM assay_cursor INTO @CName
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @CName
FETCH NEXT FROM assay_cursor
END
CLOSE assay_cursor
DEALLOCATE assay_cursor
内部循环逻辑已被删除。我想迭代代码,然后将数据转储到新的临时表中。