Sql Server游标典型例子

BEGIN
    SET NOCOUNT ON;

    DECLARE @materialid VARCHAR(50)

    DECLARE P_C CURSOR LOCAL FAST_FORWARD FOR
    SELECT materialid FROM **** WHERE ebommainid=@id;
    OPEN P_C
    FETCH NEXT FROM P_C INTO @materialid
    WHILE @@FETCH_STATUS = 0
    BEGIN
        
        --业务逻辑
        
        FETCH NEXT FROM P_C INTO @materialid
    END
    CLOSE P_C
    DEALLOCATE P_C

 

posted @ 2024-05-20 13:54  Shapley  阅读(15)  评论(0编辑  收藏  举报