• sql游标


    declare id_cursor
    CURSOR  FOR  SELECT id  FROM #t1 ----创建游标
    Open id_cursor  ---打开游标
    declare @id int,@S varchar(100), @S1 varchar(100),@S2 varchar(100),@S3 varchar(100),@publisher nvarchar(255),@addre nvarchar(255),@postcode float,@phone nvarchar(255)
    fetch next from id_cursor into @id  ---游标第一次移动并复制给参数
    select @S=出版者前缀,@publisher=出版者,@addre=地址,@postcode=邮编,@phone=联系电话
    from #t1
    where id = @id
    select @S3= right(@S,charindex('-',REVERSE(@S))-1)
    select @S2 = SUBSTRING(@S,5,1)
    select @S1=   SUBSTRING(@S,0,4)
    insert into app_Publishers_Original(EANUCC,GroupNumber,PublisherNumber,Publisher,addr,PostCode,Phone)
    values(@S1,@S2,@S3,@publisher,@addre,@postcode,@phone)
    while @@FETCH_STATUS = 0   ---循环判断游标还在读取
    begin
     fetch next from id_cursor into @id
     select @S=出版者前缀,@publisher=出版者,@addre=地址,@postcode=邮编,@phone=联系电话
     from #t1
     where id = @id
     select @S3= right(@S,charindex('-',REVERSE(@S))-1)
     select @S2 = SUBSTRING(@S,5,1)
     select @S1=   SUBSTRING(@S,0,4)
     insert into app_Publishers_Original(EANUCC,GroupNumber,PublisherNumber,Publisher,addr,PostCode, Phone)
     values(@S1,@S2,@S3,@publisher,@addre,@postcode,@phone)
    end
    close id_cursor    ----关闭游标
    deallocate id_cursor  ----删除游标

  • 相关阅读:
    lodash函数库----difference
    lodash 函数库-
    lodash函数库 -- chunk
    document.selection.createRange方法----获取用户选择文本
    复制到剪切板 clipboard
    下载图片到本地
    H5(11表格案例:小说排行榜)
    H5(10HTML标签学习)
    H5(09综合案例圣诞老人介绍)
    H5(08常用标签02,绝对,相对路径)
  • 原文地址:https://www.cnblogs.com/happygx/p/1957983.html
Copyright © 2020-2023  润新知