获取名称为'assay_cursor'的游标已存在

时间:2014-06-10 19:24:53

标签: sql-server-2008

 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

内部循环逻辑已被删除。我想迭代代码,然后将数据转储到新的临时表中。

0 个答案:

没有答案