• 批量导入表数据


    方法1:

      insert into select--->

      insert into tbl2  select id,treeLevel from tbl2

    方法2:

      select into from--->

      select id,treeLevel into tbl1 from tbl2

    示例:

    alter function dbo.tblForJson(@SuperMan varchar(50),@TreeDepth int)
    returns @tempSubGroup table(ID int identity(1,1),PersonName nvarchar(50),ParentID int,Treel int)
    as
    begin
        declare @i int   --树深度
        declare @tmpId int
        declare @curLevelInfo table(ParentID int,Person nvarchar(50))  --当前层
    
        set @i=0
        insert @tempSubGroup values(@SuperMan,0,@i) 
        while @i<@TreeDepth-1
        begin
            delete from @curLevelInfo
            insert into @curLevelInfo select ID,PersonName from @tempSubGroup where treel=@i 
            set @i=@i+1;
            insert into @tempSubGroup select junior,ParentID,@i from PTS_SubGroup 
            inner join Person on junior=Name right join @curLevelInfo on superior=Person 
            where superior=Person and treeLevel=1 and Coding=1
        end
        return
    end

      

  • 相关阅读:
    7.6实战练习
    构造方法的主要应用
    6.0字符串String
    数组冒泡排序
    数组(二维数组)
    5.1数组(一维部分)
    4个方位的三角形和菱形
    4.3循环语句
    控制台输入输出
    4 java语句 4.2条件语句
  • 原文地址:https://www.cnblogs.com/kedarui/p/3625493.html
Copyright © 2020-2023  润新知