• 各种临时表插入数据方式对比(包括自增列和GUID列)


    USE tempdb
    GO
    SET STATISTICS TIME OFF
    SET STATISTICS io OFF

    drop table #result
    create table #result
    (
    [插入行数] int ,
    [正常临时表] int,
    [行压缩临时表] int,
    [into方式创建临时表] int,
    [新加GUID列的临时表] int,
    [页压缩临时表] int,
    [行压缩临时表+新加GUID列] int,
    [页压缩临时表+新加GUID列] int,
    [新加自增列临时表] int
    )

    set nocount on

    declare @i int =0

    while @i<=5000
    begin
    begin try

    drop table #Studentid
    drop table #Studentid1
    drop table #Studentid2
    drop table #Studentid3
    drop table #Studentid4
    drop table #Studentid5
    drop table #Studentid6
    drop table #Studentid7

    end try
    begin catch
    print ''
    end catch
    declare @top int
    --select @top= CAST((select count(1) from SGPZ..student) *RAND() AS INT)
    select @top= CAST(10000 *RAND() AS INT)


    CREATE TABLE #Studentid
    (
    [StuID] [int] NOT NULL,
    [StuNum] [varchar](50) NOT NULL,
    [StuNamePY] [varchar](50) NOT NULL,
    [StuNameWB] [varchar](50) NOT NULL,
    [StuName] [varchar](50) NOT NULL,
    [IDNumber] [varchar](18) NOT NULL,
    [FileNo] [varchar](50) NULL,
    [DocType] [varchar](50) NULL,
    [Birthday] [varchar](10) NOT NULL,
    [Sex] [int] NOT NULL,
    [Height] [int] NULL,
    [DocAddress] [varchar](200) NULL,
    [Birthplace] [varchar](50) NULL,
    [ISGOT] [int] NOT NULL,
    [Address] [varchar](200) NULL,
    [ResTerm] [varchar](50) NULL,
    [Mobile] [varchar](50) NULL,
    [Tel] [varchar](50) NULL,
    [Email] [varchar](50) NULL,
    [ShuttleAddress2] [varchar](100) NULL,
    [ShuttleAddress1] [varchar](100) NULL,
    [VisitTime] [varchar](50) NULL,
    [ArrangeClass] [varchar](50) NULL,
    [BusinessWay] [varchar](50) NULL,
    [BusinessType] [varchar](50) NULL,
    [BusinessSources2] [varchar](50) NULL,
    [BusinessSources3] [varchar](50) NULL,
    [CoachDesEmpID] [int] NULL,
    [CoachDesEmpName] [varchar](50) NULL,
    [StuCoachEmpID] [int] NULL,
    [StuCoachEmpName] [varchar](50) NULL,
    [Class] [varchar](50) NULL,
    [ClassName] [varchar](4) NOT NULL,
    [ApplyType] [varchar](10) NULL,
    [CarType] [varchar](50) NOT NULL,
    [TransferType] [int] NULL,
    [MarketType] [varchar](50) NULL,
    [MarketContent] [varchar](100) NULL,
    [Gifts] [varchar](50) NULL,
    [OfferWay] [varchar](50) NULL,
    [CouponNo] [varchar](50) NULL,
    [CoType] [varchar](50) NULL,
    [IsGroup] [int] NOT NULL,
    [Remark] [varchar](2000) NULL,
    [EntryDate] [datetime] NOT NULL,
    [DjfNum] [varchar](50) NULL,
    [AreaOrganID] [int] NOT NULL,
    [AreaPointCode] [varchar](50) NOT NULL,
    [DeptOrganID] [int] NOT NULL,
    [DeptPointCode] [varchar](50) NOT NULL,
    [ConEmpID] [int] NOT NULL,
    [ConEmpName] [varchar](50) NOT NULL,
    [ConEmpTel] [varchar](50) NULL,
    [InDate] [datetime] NOT NULL,
    [AddEmpID] [int] NOT NULL,
    [AddEmpName] [varchar](50) NOT NULL,
    [OrganID] [int] NOT NULL,
    [JlClassName] [varchar](50) NULL,
    [IsDel] [int] NOT NULL,
    [AuState] [int] NOT NULL,
    [AuEmpID] [int] NULL,
    [AuTime] [datetime] NULL,
    [IsInternal] [int] NOT NULL,
    [StuInTime] [datetime] NULL,
    [SLRQ] [datetime] NULL,
    [LSH] [int] NULL,
    [StuType] [int] NOT NULL,
    [PrioCoachID] [int] NULL,
    [PrioCoachName] [varchar](50) NULL
    )

    CREATE TABLE #Studentid2
    (
    [StuID] [int] NOT NULL,
    [StuNum] [varchar](50) NOT NULL,
    [StuNamePY] [varchar](50) NOT NULL,
    [StuNameWB] [varchar](50) NOT NULL,
    [StuName] [varchar](50) NOT NULL,
    [IDNumber] [varchar](18) NOT NULL,
    [FileNo] [varchar](50) NULL,
    [DocType] [varchar](50) NULL,
    [Birthday] [varchar](10) NOT NULL,
    [Sex] [int] NOT NULL,
    [Height] [int] NULL,
    [DocAddress] [varchar](200) NULL,
    [Birthplace] [varchar](50) NULL,
    [ISGOT] [int] NOT NULL,
    [Address] [varchar](200) NULL,
    [ResTerm] [varchar](50) NULL,
    [Mobile] [varchar](50) NULL,
    [Tel] [varchar](50) NULL,
    [Email] [varchar](50) NULL,
    [ShuttleAddress2] [varchar](100) NULL,
    [ShuttleAddress1] [varchar](100) NULL,
    [VisitTime] [varchar](50) NULL,
    [ArrangeClass] [varchar](50) NULL,
    [BusinessWay] [varchar](50) NULL,
    [BusinessType] [varchar](50) NULL,
    [BusinessSources2] [varchar](50) NULL,
    [BusinessSources3] [varchar](50) NULL,
    [CoachDesEmpID] [int] NULL,
    [CoachDesEmpName] [varchar](50) NULL,
    [StuCoachEmpID] [int] NULL,
    [StuCoachEmpName] [varchar](50) NULL,
    [Class] [varchar](50) NULL,
    [ClassName] [varchar](4) NOT NULL,
    [ApplyType] [varchar](10) NULL,
    [CarType] [varchar](50) NOT NULL,
    [TransferType] [int] NULL,
    [MarketType] [varchar](50) NULL,
    [MarketContent] [varchar](100) NULL,
    [Gifts] [varchar](50) NULL,
    [OfferWay] [varchar](50) NULL,
    [CouponNo] [varchar](50) NULL,
    [CoType] [varchar](50) NULL,
    [IsGroup] [int] NOT NULL,
    [Remark] [varchar](2000) NULL,
    [EntryDate] [datetime] NOT NULL,
    [DjfNum] [varchar](50) NULL,
    [AreaOrganID] [int] NOT NULL,
    [AreaPointCode] [varchar](50) NOT NULL,
    [DeptOrganID] [int] NOT NULL,
    [DeptPointCode] [varchar](50) NOT NULL,
    [ConEmpID] [int] NOT NULL,
    [ConEmpName] [varchar](50) NOT NULL,
    [ConEmpTel] [varchar](50) NULL,
    [InDate] [datetime] NOT NULL,
    [AddEmpID] [int] NOT NULL,
    [AddEmpName] [varchar](50) NOT NULL,
    [OrganID] [int] NOT NULL,
    [JlClassName] [varchar](50) NULL,
    [IsDel] [int] NOT NULL,
    [AuState] [int] NOT NULL,
    [AuEmpID] [int] NULL,
    [AuTime] [datetime] NULL,
    [IsInternal] [int] NOT NULL,
    [StuInTime] [datetime] NULL,
    [SLRQ] [datetime] NULL,
    [LSH] [int] NULL,
    [StuType] [int] NOT NULL,
    [PrioCoachID] [int] NULL,
    [PrioCoachName] [varchar](50) NULL
    )
    with ( data_compression= row )

    CREATE TABLE #Studentid3
    (
    GUIDID uniqueidentifier DEFAULT (NEWSEQUENTIALID()),
    [StuID] [int] NOT NULL,
    [StuNum] [varchar](50) NOT NULL,
    [StuNamePY] [varchar](50) NOT NULL,
    [StuNameWB] [varchar](50) NOT NULL,
    [StuName] [varchar](50) NOT NULL,
    [IDNumber] [varchar](18) NOT NULL,
    [FileNo] [varchar](50) NULL,
    [DocType] [varchar](50) NULL,
    [Birthday] [varchar](10) NOT NULL,
    [Sex] [int] NOT NULL,
    [Height] [int] NULL,
    [DocAddress] [varchar](200) NULL,
    [Birthplace] [varchar](50) NULL,
    [ISGOT] [int] NOT NULL,
    [Address] [varchar](200) NULL,
    [ResTerm] [varchar](50) NULL,
    [Mobile] [varchar](50) NULL,
    [Tel] [varchar](50) NULL,
    [Email] [varchar](50) NULL,
    [ShuttleAddress2] [varchar](100) NULL,
    [ShuttleAddress1] [varchar](100) NULL,
    [VisitTime] [varchar](50) NULL,
    [ArrangeClass] [varchar](50) NULL,
    [BusinessWay] [varchar](50) NULL,
    [BusinessType] [varchar](50) NULL,
    [BusinessSources2] [varchar](50) NULL,
    [BusinessSources3] [varchar](50) NULL,
    [CoachDesEmpID] [int] NULL,
    [CoachDesEmpName] [varchar](50) NULL,
    [StuCoachEmpID] [int] NULL,
    [StuCoachEmpName] [varchar](50) NULL,
    [Class] [varchar](50) NULL,
    [ClassName] [varchar](4) NOT NULL,
    [ApplyType] [varchar](10) NULL,
    [CarType] [varchar](50) NOT NULL,
    [TransferType] [int] NULL,
    [MarketType] [varchar](50) NULL,
    [MarketContent] [varchar](100) NULL,
    [Gifts] [varchar](50) NULL,
    [OfferWay] [varchar](50) NULL,
    [CouponNo] [varchar](50) NULL,
    [CoType] [varchar](50) NULL,
    [IsGroup] [int] NOT NULL,
    [Remark] [varchar](2000) NULL,
    [EntryDate] [datetime] NOT NULL,
    [DjfNum] [varchar](50) NULL,
    [AreaOrganID] [int] NOT NULL,
    [AreaPointCode] [varchar](50) NOT NULL,
    [DeptOrganID] [int] NOT NULL,
    [DeptPointCode] [varchar](50) NOT NULL,
    [ConEmpID] [int] NOT NULL,
    [ConEmpName] [varchar](50) NOT NULL,
    [ConEmpTel] [varchar](50) NULL,
    [InDate] [datetime] NOT NULL,
    [AddEmpID] [int] NOT NULL,
    [AddEmpName] [varchar](50) NOT NULL,
    [OrganID] [int] NOT NULL,
    [JlClassName] [varchar](50) NULL,
    [IsDel] [int] NOT NULL,
    [AuState] [int] NOT NULL,
    [AuEmpID] [int] NULL,
    [AuTime] [datetime] NULL,
    [IsInternal] [int] NOT NULL,
    [StuInTime] [datetime] NULL,
    [SLRQ] [datetime] NULL,
    [LSH] [int] NULL,
    [StuType] [int] NOT NULL,
    [PrioCoachID] [int] NULL,
    [PrioCoachName] [varchar](50) NULL
    )

    CREATE TABLE #Studentid4
    (
    [StuID] [int] NOT NULL,
    [StuNum] [varchar](50) NOT NULL,
    [StuNamePY] [varchar](50) NOT NULL,
    [StuNameWB] [varchar](50) NOT NULL,
    [StuName] [varchar](50) NOT NULL,
    [IDNumber] [varchar](18) NOT NULL,
    [FileNo] [varchar](50) NULL,
    [DocType] [varchar](50) NULL,
    [Birthday] [varchar](10) NOT NULL,
    [Sex] [int] NOT NULL,
    [Height] [int] NULL,
    [DocAddress] [varchar](200) NULL,
    [Birthplace] [varchar](50) NULL,
    [ISGOT] [int] NOT NULL,
    [Address] [varchar](200) NULL,
    [ResTerm] [varchar](50) NULL,
    [Mobile] [varchar](50) NULL,
    [Tel] [varchar](50) NULL,
    [Email] [varchar](50) NULL,
    [ShuttleAddress2] [varchar](100) NULL,
    [ShuttleAddress1] [varchar](100) NULL,
    [VisitTime] [varchar](50) NULL,
    [ArrangeClass] [varchar](50) NULL,
    [BusinessWay] [varchar](50) NULL,
    [BusinessType] [varchar](50) NULL,
    [BusinessSources2] [varchar](50) NULL,
    [BusinessSources3] [varchar](50) NULL,
    [CoachDesEmpID] [int] NULL,
    [CoachDesEmpName] [varchar](50) NULL,
    [StuCoachEmpID] [int] NULL,
    [StuCoachEmpName] [varchar](50) NULL,
    [Class] [varchar](50) NULL,
    [ClassName] [varchar](4) NOT NULL,
    [ApplyType] [varchar](10) NULL,
    [CarType] [varchar](50) NOT NULL,
    [TransferType] [int] NULL,
    [MarketType] [varchar](50) NULL,
    [MarketContent] [varchar](100) NULL,
    [Gifts] [varchar](50) NULL,
    [OfferWay] [varchar](50) NULL,
    [CouponNo] [varchar](50) NULL,
    [CoType] [varchar](50) NULL,
    [IsGroup] [int] NOT NULL,
    [Remark] [varchar](2000) NULL,
    [EntryDate] [datetime] NOT NULL,
    [DjfNum] [varchar](50) NULL,
    [AreaOrganID] [int] NOT NULL,
    [AreaPointCode] [varchar](50) NOT NULL,
    [DeptOrganID] [int] NOT NULL,
    [DeptPointCode] [varchar](50) NOT NULL,
    [ConEmpID] [int] NOT NULL,
    [ConEmpName] [varchar](50) NOT NULL,
    [ConEmpTel] [varchar](50) NULL,
    [InDate] [datetime] NOT NULL,
    [AddEmpID] [int] NOT NULL,
    [AddEmpName] [varchar](50) NOT NULL,
    [OrganID] [int] NOT NULL,
    [JlClassName] [varchar](50) NULL,
    [IsDel] [int] NOT NULL,
    [AuState] [int] NOT NULL,
    [AuEmpID] [int] NULL,
    [AuTime] [datetime] NULL,
    [IsInternal] [int] NOT NULL,
    [StuInTime] [datetime] NULL,
    [SLRQ] [datetime] NULL,
    [LSH] [int] NULL,
    [StuType] [int] NOT NULL,
    [PrioCoachID] [int] NULL,
    [PrioCoachName] [varchar](50) NULL
    )
    with ( data_compression= page )

    CREATE TABLE #Studentid5
    (
    GUIDID uniqueidentifier DEFAULT (NEWSEQUENTIALID()),
    [StuID] [int] NOT NULL,
    [StuNum] [varchar](50) NOT NULL,
    [StuNamePY] [varchar](50) NOT NULL,
    [StuNameWB] [varchar](50) NOT NULL,
    [StuName] [varchar](50) NOT NULL,
    [IDNumber] [varchar](18) NOT NULL,
    [FileNo] [varchar](50) NULL,
    [DocType] [varchar](50) NULL,
    [Birthday] [varchar](10) NOT NULL,
    [Sex] [int] NOT NULL,
    [Height] [int] NULL,
    [DocAddress] [varchar](200) NULL,
    [Birthplace] [varchar](50) NULL,
    [ISGOT] [int] NOT NULL,
    [Address] [varchar](200) NULL,
    [ResTerm] [varchar](50) NULL,
    [Mobile] [varchar](50) NULL,
    [Tel] [varchar](50) NULL,
    [Email] [varchar](50) NULL,
    [ShuttleAddress2] [varchar](100) NULL,
    [ShuttleAddress1] [varchar](100) NULL,
    [VisitTime] [varchar](50) NULL,
    [ArrangeClass] [varchar](50) NULL,
    [BusinessWay] [varchar](50) NULL,
    [BusinessType] [varchar](50) NULL,
    [BusinessSources2] [varchar](50) NULL,
    [BusinessSources3] [varchar](50) NULL,
    [CoachDesEmpID] [int] NULL,
    [CoachDesEmpName] [varchar](50) NULL,
    [StuCoachEmpID] [int] NULL,
    [StuCoachEmpName] [varchar](50) NULL,
    [Class] [varchar](50) NULL,
    [ClassName] [varchar](4) NOT NULL,
    [ApplyType] [varchar](10) NULL,
    [CarType] [varchar](50) NOT NULL,
    [TransferType] [int] NULL,
    [MarketType] [varchar](50) NULL,
    [MarketContent] [varchar](100) NULL,
    [Gifts] [varchar](50) NULL,
    [OfferWay] [varchar](50) NULL,
    [CouponNo] [varchar](50) NULL,
    [CoType] [varchar](50) NULL,
    [IsGroup] [int] NOT NULL,
    [Remark] [varchar](2000) NULL,
    [EntryDate] [datetime] NOT NULL,
    [DjfNum] [varchar](50) NULL,
    [AreaOrganID] [int] NOT NULL,
    [AreaPointCode] [varchar](50) NOT NULL,
    [DeptOrganID] [int] NOT NULL,
    [DeptPointCode] [varchar](50) NOT NULL,
    [ConEmpID] [int] NOT NULL,
    [ConEmpName] [varchar](50) NOT NULL,
    [ConEmpTel] [varchar](50) NULL,
    [InDate] [datetime] NOT NULL,
    [AddEmpID] [int] NOT NULL,
    [AddEmpName] [varchar](50) NOT NULL,
    [OrganID] [int] NOT NULL,
    [JlClassName] [varchar](50) NULL,
    [IsDel] [int] NOT NULL,
    [AuState] [int] NOT NULL,
    [AuEmpID] [int] NULL,
    [AuTime] [datetime] NULL,
    [IsInternal] [int] NOT NULL,
    [StuInTime] [datetime] NULL,
    [SLRQ] [datetime] NULL,
    [LSH] [int] NULL,
    [StuType] [int] NOT NULL,
    [PrioCoachID] [int] NULL,
    [PrioCoachName] [varchar](50) NULL
    )
    with ( data_compression= row )

    CREATE TABLE #Studentid6
    (
    GUIDID uniqueidentifier DEFAULT (NEWSEQUENTIALID()),
    [StuID] [int] NOT NULL,
    [StuNum] [varchar](50) NOT NULL,
    [StuNamePY] [varchar](50) NOT NULL,
    [StuNameWB] [varchar](50) NOT NULL,
    [StuName] [varchar](50) NOT NULL,
    [IDNumber] [varchar](18) NOT NULL,
    [FileNo] [varchar](50) NULL,
    [DocType] [varchar](50) NULL,
    [Birthday] [varchar](10) NOT NULL,
    [Sex] [int] NOT NULL,
    [Height] [int] NULL,
    [DocAddress] [varchar](200) NULL,
    [Birthplace] [varchar](50) NULL,
    [ISGOT] [int] NOT NULL,
    [Address] [varchar](200) NULL,
    [ResTerm] [varchar](50) NULL,
    [Mobile] [varchar](50) NULL,
    [Tel] [varchar](50) NULL,
    [Email] [varchar](50) NULL,
    [ShuttleAddress2] [varchar](100) NULL,
    [ShuttleAddress1] [varchar](100) NULL,
    [VisitTime] [varchar](50) NULL,
    [ArrangeClass] [varchar](50) NULL,
    [BusinessWay] [varchar](50) NULL,
    [BusinessType] [varchar](50) NULL,
    [BusinessSources2] [varchar](50) NULL,
    [BusinessSources3] [varchar](50) NULL,
    [CoachDesEmpID] [int] NULL,
    [CoachDesEmpName] [varchar](50) NULL,
    [StuCoachEmpID] [int] NULL,
    [StuCoachEmpName] [varchar](50) NULL,
    [Class] [varchar](50) NULL,
    [ClassName] [varchar](4) NOT NULL,
    [ApplyType] [varchar](10) NULL,
    [CarType] [varchar](50) NOT NULL,
    [TransferType] [int] NULL,
    [MarketType] [varchar](50) NULL,
    [MarketContent] [varchar](100) NULL,
    [Gifts] [varchar](50) NULL,
    [OfferWay] [varchar](50) NULL,
    [CouponNo] [varchar](50) NULL,
    [CoType] [varchar](50) NULL,
    [IsGroup] [int] NOT NULL,
    [Remark] [varchar](2000) NULL,
    [EntryDate] [datetime] NOT NULL,
    [DjfNum] [varchar](50) NULL,
    [AreaOrganID] [int] NOT NULL,
    [AreaPointCode] [varchar](50) NOT NULL,
    [DeptOrganID] [int] NOT NULL,
    [DeptPointCode] [varchar](50) NOT NULL,
    [ConEmpID] [int] NOT NULL,
    [ConEmpName] [varchar](50) NOT NULL,
    [ConEmpTel] [varchar](50) NULL,
    [InDate] [datetime] NOT NULL,
    [AddEmpID] [int] NOT NULL,
    [AddEmpName] [varchar](50) NOT NULL,
    [OrganID] [int] NOT NULL,
    [JlClassName] [varchar](50) NULL,
    [IsDel] [int] NOT NULL,
    [AuState] [int] NOT NULL,
    [AuEmpID] [int] NULL,
    [AuTime] [datetime] NULL,
    [IsInternal] [int] NOT NULL,
    [StuInTime] [datetime] NULL,
    [SLRQ] [datetime] NULL,
    [LSH] [int] NULL,
    [StuType] [int] NOT NULL,
    [PrioCoachID] [int] NULL,
    [PrioCoachName] [varchar](50) NULL
    )
    with ( data_compression= page )

    CREATE TABLE #Studentid7
    (
    ID int identity(1,1),
    [StuID] [int] NOT NULL,
    [StuNum] [varchar](50) NOT NULL,
    [StuNamePY] [varchar](50) NOT NULL,
    [StuNameWB] [varchar](50) NOT NULL,
    [StuName] [varchar](50) NOT NULL,
    [IDNumber] [varchar](18) NOT NULL,
    [FileNo] [varchar](50) NULL,
    [DocType] [varchar](50) NULL,
    [Birthday] [varchar](10) NOT NULL,
    [Sex] [int] NOT NULL,
    [Height] [int] NULL,
    [DocAddress] [varchar](200) NULL,
    [Birthplace] [varchar](50) NULL,
    [ISGOT] [int] NOT NULL,
    [Address] [varchar](200) NULL,
    [ResTerm] [varchar](50) NULL,
    [Mobile] [varchar](50) NULL,
    [Tel] [varchar](50) NULL,
    [Email] [varchar](50) NULL,
    [ShuttleAddress2] [varchar](100) NULL,
    [ShuttleAddress1] [varchar](100) NULL,
    [VisitTime] [varchar](50) NULL,
    [ArrangeClass] [varchar](50) NULL,
    [BusinessWay] [varchar](50) NULL,
    [BusinessType] [varchar](50) NULL,
    [BusinessSources2] [varchar](50) NULL,
    [BusinessSources3] [varchar](50) NULL,
    [CoachDesEmpID] [int] NULL,
    [CoachDesEmpName] [varchar](50) NULL,
    [StuCoachEmpID] [int] NULL,
    [StuCoachEmpName] [varchar](50) NULL,
    [Class] [varchar](50) NULL,
    [ClassName] [varchar](4) NOT NULL,
    [ApplyType] [varchar](10) NULL,
    [CarType] [varchar](50) NOT NULL,
    [TransferType] [int] NULL,
    [MarketType] [varchar](50) NULL,
    [MarketContent] [varchar](100) NULL,
    [Gifts] [varchar](50) NULL,
    [OfferWay] [varchar](50) NULL,
    [CouponNo] [varchar](50) NULL,
    [CoType] [varchar](50) NULL,
    [IsGroup] [int] NOT NULL,
    [Remark] [varchar](2000) NULL,
    [EntryDate] [datetime] NOT NULL,
    [DjfNum] [varchar](50) NULL,
    [AreaOrganID] [int] NOT NULL,
    [AreaPointCode] [varchar](50) NOT NULL,
    [DeptOrganID] [int] NOT NULL,
    [DeptPointCode] [varchar](50) NOT NULL,
    [ConEmpID] [int] NOT NULL,
    [ConEmpName] [varchar](50) NOT NULL,
    [ConEmpTel] [varchar](50) NULL,
    [InDate] [datetime] NOT NULL,
    [AddEmpID] [int] NOT NULL,
    [AddEmpName] [varchar](50) NOT NULL,
    [OrganID] [int] NOT NULL,
    [JlClassName] [varchar](50) NULL,
    [IsDel] [int] NOT NULL,
    [AuState] [int] NOT NULL,
    [AuEmpID] [int] NULL,
    [AuTime] [datetime] NULL,
    [IsInternal] [int] NOT NULL,
    [StuInTime] [datetime] NULL,
    [SLRQ] [datetime] NULL,
    [LSH] [int] NULL,
    [StuType] [int] NOT NULL,
    [PrioCoachID] [int] NULL,
    [PrioCoachName] [varchar](50) NULL
    )
    with ( data_compression= page )
    SET STATISTICS TIME OFF
    SET STATISTICS io OFF

    declare @t1 int
    declare @t2 int
    declare @t3 int
    declare @t4 int
    declare @t5 int
    declare @t6 int
    declare @t7 int
    declare @t8 int




    DECLARE @d DATETIME
    SET @d = GETDATE()
    --Script.Start
    insert #Studentid
    select TOP (@TOP)* from SGPZ..student
    --Script.End
    set @t1= DATEDIFF(ms, @d, GETDATE())


    DECLARE @d1 DATETIME
    SET @d1 = GETDATE()
    insert #Studentid2
    select TOP (@TOP) * from SGPZ..student
    set @t2= DATEDIFF(ms, @d1, GETDATE())

    DECLARE @d2 DATETIME
    SET @d2 = GETDATE()
    select TOP (@TOP) * into #Studentid1 from SGPZ..student
    set @t3= DATEDIFF(ms, @d2, GETDATE())

    DECLARE @d3 DATETIME
    SET @d3 = GETDATE()
    insert into #studentid3 ([StuName],[StuID],[StuNum],[StuNamePY],[StuNameWB],
    [IDNumber],[FileNo],[DocType],[Birthday],[Sex],
    [Height],[DocAddress],[Birthplace],[ISGOT],[Address],
    [ResTerm],[Mobile],[Tel],[Email],[ShuttleAddress2],
    [ShuttleAddress1],[VisitTime],[ArrangeClass],
    [BusinessWay],[BusinessType],[BusinessSources2],
    [BusinessSources3],[CoachDesEmpID],[CoachDesEmpName],
    [StuCoachEmpID],[StuCoachEmpName],[Class],[ClassName],
    [ApplyType],[CarType],[TransferType],[MarketType],
    [MarketContent],[Gifts],[OfferWay],[CouponNo],[CoType],
    [IsGroup],[Remark],[EntryDate],[DjfNum],[AreaOrganID],
    [AreaPointCode],[DeptOrganID],[DeptPointCode],
    [ConEmpID],[ConEmpName],[ConEmpTel],[InDate],
    [AddEmpID],[AddEmpName],[OrganID],[JlClassName],
    [IsDel],[AuState],[AuEmpID],[AuTime],[IsInternal],
    [StuInTime],[SLRQ],[LSH],[StuType],[PrioCoachID],
    [PrioCoachName])
    select TOP (@TOP) [StuName],[StuID],[StuNum],[StuNamePY],[StuNameWB],[IDNumber],
    [FileNo],[DocType],[Birthday],[Sex],[Height],[DocAddress],[Birthplace],
    [ISGOT],[Address],[ResTerm],[Mobile],[Tel],[Email],[ShuttleAddress2],
    [ShuttleAddress1],[VisitTime],[ArrangeClass],[BusinessWay],
    [BusinessType],[BusinessSources2],[BusinessSources3],[CoachDesEmpID],
    [CoachDesEmpName],[StuCoachEmpID],[StuCoachEmpName],[Class],
    [ClassName],[ApplyType],[CarType],[TransferType],[MarketType],
    [MarketContent],[Gifts],[OfferWay],[CouponNo],[CoType],[IsGroup],
    [Remark],[EntryDate],[DjfNum],[AreaOrganID],[AreaPointCode],
    [DeptOrganID],[DeptPointCode],[ConEmpID],[ConEmpName],[ConEmpTel],
    [InDate],[AddEmpID],[AddEmpName],[OrganID],[JlClassName],[IsDel],
    [AuState],[AuEmpID],[AuTime],[IsInternal],[StuInTime],[SLRQ],[LSH],
    [StuType],[PrioCoachID],[PrioCoachName]
    from SGPZ..student
    set @t4= DATEDIFF(ms, @d3, GETDATE())


    DECLARE @d4 DATETIME
    SET @d4 = GETDATE()
    insert #Studentid4
    select TOP (@TOP) * from SGPZ..student
    set @t5= DATEDIFF(ms, @d4, GETDATE())

    DECLARE @d5 DATETIME
    SET @d5 = GETDATE()
    insert into #studentid5 ([StuName],[StuID],[StuNum],[StuNamePY],[StuNameWB],
    [IDNumber],[FileNo],[DocType],[Birthday],[Sex],
    [Height],[DocAddress],[Birthplace],[ISGOT],[Address],
    [ResTerm],[Mobile],[Tel],[Email],[ShuttleAddress2],
    [ShuttleAddress1],[VisitTime],[ArrangeClass],
    [BusinessWay],[BusinessType],[BusinessSources2],
    [BusinessSources3],[CoachDesEmpID],[CoachDesEmpName],
    [StuCoachEmpID],[StuCoachEmpName],[Class],[ClassName],
    [ApplyType],[CarType],[TransferType],[MarketType],
    [MarketContent],[Gifts],[OfferWay],[CouponNo],[CoType],
    [IsGroup],[Remark],[EntryDate],[DjfNum],[AreaOrganID],
    [AreaPointCode],[DeptOrganID],[DeptPointCode],
    [ConEmpID],[ConEmpName],[ConEmpTel],[InDate],
    [AddEmpID],[AddEmpName],[OrganID],[JlClassName],
    [IsDel],[AuState],[AuEmpID],[AuTime],[IsInternal],
    [StuInTime],[SLRQ],[LSH],[StuType],[PrioCoachID],
    [PrioCoachName])
    select TOP (@TOP) [StuName],[StuID],[StuNum],[StuNamePY],[StuNameWB],[IDNumber],
    [FileNo],[DocType],[Birthday],[Sex],[Height],[DocAddress],[Birthplace],
    [ISGOT],[Address],[ResTerm],[Mobile],[Tel],[Email],[ShuttleAddress2],
    [ShuttleAddress1],[VisitTime],[ArrangeClass],[BusinessWay],
    [BusinessType],[BusinessSources2],[BusinessSources3],[CoachDesEmpID],
    [CoachDesEmpName],[StuCoachEmpID],[StuCoachEmpName],[Class],
    [ClassName],[ApplyType],[CarType],[TransferType],[MarketType],
    [MarketContent],[Gifts],[OfferWay],[CouponNo],[CoType],[IsGroup],
    [Remark],[EntryDate],[DjfNum],[AreaOrganID],[AreaPointCode],
    [DeptOrganID],[DeptPointCode],[ConEmpID],[ConEmpName],[ConEmpTel],
    [InDate],[AddEmpID],[AddEmpName],[OrganID],[JlClassName],[IsDel],
    [AuState],[AuEmpID],[AuTime],[IsInternal],[StuInTime],[SLRQ],[LSH],
    [StuType],[PrioCoachID],[PrioCoachName]
    from SGPZ..student
    set @t6= DATEDIFF(ms, @d5, GETDATE())


    DECLARE @d6 DATETIME
    SET @d6 = GETDATE()
    insert into #studentid6 ([StuName],[StuID],[StuNum],[StuNamePY],[StuNameWB],
    [IDNumber],[FileNo],[DocType],[Birthday],[Sex],
    [Height],[DocAddress],[Birthplace],[ISGOT],[Address],
    [ResTerm],[Mobile],[Tel],[Email],[ShuttleAddress2],
    [ShuttleAddress1],[VisitTime],[ArrangeClass],
    [BusinessWay],[BusinessType],[BusinessSources2],
    [BusinessSources3],[CoachDesEmpID],[CoachDesEmpName],
    [StuCoachEmpID],[StuCoachEmpName],[Class],[ClassName],
    [ApplyType],[CarType],[TransferType],[MarketType],
    [MarketContent],[Gifts],[OfferWay],[CouponNo],[CoType],
    [IsGroup],[Remark],[EntryDate],[DjfNum],[AreaOrganID],
    [AreaPointCode],[DeptOrganID],[DeptPointCode],
    [ConEmpID],[ConEmpName],[ConEmpTel],[InDate],
    [AddEmpID],[AddEmpName],[OrganID],[JlClassName],
    [IsDel],[AuState],[AuEmpID],[AuTime],[IsInternal],
    [StuInTime],[SLRQ],[LSH],[StuType],[PrioCoachID],
    [PrioCoachName])
    select TOP (@TOP) [StuName],[StuID],[StuNum],[StuNamePY],[StuNameWB],[IDNumber],
    [FileNo],[DocType],[Birthday],[Sex],[Height],[DocAddress],[Birthplace],
    [ISGOT],[Address],[ResTerm],[Mobile],[Tel],[Email],[ShuttleAddress2],
    [ShuttleAddress1],[VisitTime],[ArrangeClass],[BusinessWay],
    [BusinessType],[BusinessSources2],[BusinessSources3],[CoachDesEmpID],
    [CoachDesEmpName],[StuCoachEmpID],[StuCoachEmpName],[Class],
    [ClassName],[ApplyType],[CarType],[TransferType],[MarketType],
    [MarketContent],[Gifts],[OfferWay],[CouponNo],[CoType],[IsGroup],
    [Remark],[EntryDate],[DjfNum],[AreaOrganID],[AreaPointCode],
    [DeptOrganID],[DeptPointCode],[ConEmpID],[ConEmpName],[ConEmpTel],
    [InDate],[AddEmpID],[AddEmpName],[OrganID],[JlClassName],[IsDel],
    [AuState],[AuEmpID],[AuTime],[IsInternal],[StuInTime],[SLRQ],[LSH],
    [StuType],[PrioCoachID],[PrioCoachName]
    from SGPZ..student
    set @t7= DATEDIFF(ms, @d6, GETDATE())


    DECLARE @d7 DATETIME
    SET @d7 = GETDATE()
    insert into #studentid7 ([StuName],[StuID],[StuNum],[StuNamePY],[StuNameWB],
    [IDNumber],[FileNo],[DocType],[Birthday],[Sex],
    [Height],[DocAddress],[Birthplace],[ISGOT],[Address],
    [ResTerm],[Mobile],[Tel],[Email],[ShuttleAddress2],
    [ShuttleAddress1],[VisitTime],[ArrangeClass],
    [BusinessWay],[BusinessType],[BusinessSources2],
    [BusinessSources3],[CoachDesEmpID],[CoachDesEmpName],
    [StuCoachEmpID],[StuCoachEmpName],[Class],[ClassName],
    [ApplyType],[CarType],[TransferType],[MarketType],
    [MarketContent],[Gifts],[OfferWay],[CouponNo],[CoType],
    [IsGroup],[Remark],[EntryDate],[DjfNum],[AreaOrganID],
    [AreaPointCode],[DeptOrganID],[DeptPointCode],
    [ConEmpID],[ConEmpName],[ConEmpTel],[InDate],
    [AddEmpID],[AddEmpName],[OrganID],[JlClassName],
    [IsDel],[AuState],[AuEmpID],[AuTime],[IsInternal],
    [StuInTime],[SLRQ],[LSH],[StuType],[PrioCoachID],
    [PrioCoachName])
    select TOP (@TOP) [StuName],[StuID],[StuNum],[StuNamePY],[StuNameWB],[IDNumber],
    [FileNo],[DocType],[Birthday],[Sex],[Height],[DocAddress],[Birthplace],
    [ISGOT],[Address],[ResTerm],[Mobile],[Tel],[Email],[ShuttleAddress2],
    [ShuttleAddress1],[VisitTime],[ArrangeClass],[BusinessWay],
    [BusinessType],[BusinessSources2],[BusinessSources3],[CoachDesEmpID],
    [CoachDesEmpName],[StuCoachEmpID],[StuCoachEmpName],[Class],
    [ClassName],[ApplyType],[CarType],[TransferType],[MarketType],
    [MarketContent],[Gifts],[OfferWay],[CouponNo],[CoType],[IsGroup],
    [Remark],[EntryDate],[DjfNum],[AreaOrganID],[AreaPointCode],
    [DeptOrganID],[DeptPointCode],[ConEmpID],[ConEmpName],[ConEmpTel],
    [InDate],[AddEmpID],[AddEmpName],[OrganID],[JlClassName],[IsDel],
    [AuState],[AuEmpID],[AuTime],[IsInternal],[StuInTime],[SLRQ],[LSH],
    [StuType],[PrioCoachID],[PrioCoachName]
    from SGPZ..student
    set @t8= DATEDIFF(ms, @d7, GETDATE())


    insert #result
    select @TOP,@t1, @t2, @t3, @t4,@t5, @t6,@t7 ,@t8


    set @i=@i+1
    end

    --select ([正常临时表]),([行压缩临时表]),([into方式创建临时表]),([新加GUID列的临时表]),([页压缩临时表]),
    -- ([行压缩临时表+新加GUID列]),([页压缩临时表+新加GUID列])
    -- from #result
    ----union all
    ----select MAX([正常临时表]),MAX([行压缩临时表]),MAX([into方式创建临时表]),MAX([新加GUID列的临时表]),
    ---- MAX([页压缩临时表]),MAX([行压缩临时表+新加GUID列]),MAX([页压缩临时表+新加GUID列])
    ---- from #result
    ----union all
    ----select min([正常临时表]),min([行压缩临时表]),min([into方式创建临时表]),min([新加GUID列的临时表]),
    ---- min([页压缩临时表]),min([行压缩临时表+新加GUID列]),min([页压缩临时表+新加GUID列])
    ---- from #result
    --union all
    --select
    --avg([正常临时表]) [正常临时表],
    --avg([行压缩临时表]) [行压缩临时表],
    --avg([into方式创建临时表]) [into方式创建临时表],
    --avg([新加GUID列的临时表]) [新加GUID列的临时表],
    --avg([页压缩临时表]) [页压缩临时表],
    --avg([行压缩临时表+新加GUID列]) [行压缩临时表+新加GUID列],
    --avg([页压缩临时表+新加GUID列]) [页压缩临时表+新加GUID列],
    --avg([新加自增列临时表]) [新加自增列临时表]
    -- from #result
    -- where 1=1
    -- and [正常临时表] not in (select top 20 [正常临时表] from #result order by [正常临时表] desc )
    -- and [正常临时表] not in (select top 20 [正常临时表] from #result order by [正常临时表] )
    -- and [行压缩临时表] not in (select top 20 [行压缩临时表] from #result order by [行压缩临时表] desc )
    -- and [行压缩临时表] not in (select top 20 [行压缩临时表] from #result order by [行压缩临时表] )
    -- and [into方式创建临时表] not in (select top 20 [into方式创建临时表]from #result order by [into方式创建临时表] desc)
    -- and [into方式创建临时表] not in (select top 20 [into方式创建临时表]from #result order by [into方式创建临时表] )
    -- and [新加GUID列的临时表] not in (select top 20 [新加GUID列的临时表] from #result order by [新加GUID列的临时表] desc )
    -- and [新加GUID列的临时表] not in (select top 20 [新加GUID列的临时表] from #result order by [新加GUID列的临时表])
    -- and [页压缩临时表] not in (select top 20 [页压缩临时表] from #result order by[页压缩临时表] desc )
    -- and [页压缩临时表] not in (select top 20 [页压缩临时表] from #result order by[页压缩临时表])
    -- and [行压缩临时表+新加GUID列] not in (select top 20 [行压缩临时表+新加GUID列] from #result order by [行压缩临时表+新加GUID列] desc )
    -- and [行压缩临时表+新加GUID列] not in (select top 20 [行压缩临时表+新加GUID列] from #result order by [行压缩临时表+新加GUID列] )
    -- and [页压缩临时表+新加GUID列] not in (select top 20 [页压缩临时表+新加GUID列] from #result order by [页压缩临时表+新加GUID列] desc )
    -- and [页压缩临时表+新加GUID列] not in (select top 20 [页压缩临时表+新加GUID列] from #result order by [页压缩临时表+新加GUID列])
    -- and [新加自增列临时表] not in (select top 20 [新加自增列临时表] from #result order by [新加自增列临时表] desc )
    -- and [新加自增列临时表] not in (select top 20 [新加自增列临时表] from #result order by [新加自增列临时表])


    -------------------------------------------------------------------------------------------------------------------------
    select (
    select avg([正常临时表]) [正常临时表]
    from #result
    where 1=1
    and [正常临时表] not in (select top 50 [正常临时表]
    from #result
    order by [正常临时表] desc)
    and [正常临时表] not in (select top 50 [正常临时表]
    from #result
    order by [正常临时表])
    ) [正常临时表],(
    select avg([行压缩临时表]) [行压缩临时表]
    from #result
    where 1=1
    and [行压缩临时表] not in (select top 50 [行压缩临时表]
    from #result
    order by [行压缩临时表] desc)
    and [行压缩临时表] not in (select top 50 [行压缩临时表]
    from #result
    order by [行压缩临时表])
    ) [行压缩临时表],
    (
    select avg([into方式创建临时表]) [into方式创建临时表]
    from #result
    where 1=1
    and [into方式创建临时表] not in (select top 50 [into方式创建临时表]
    from #result
    order by [into方式创建临时表] desc)
    and [into方式创建临时表] not in (select top 50 [into方式创建临时表]
    from #result
    order by [into方式创建临时表])
    ) [into方式创建临时表],
    (
    select avg([新加GUID列的临时表]) [新加GUID列的临时表]
    from #result
    where 1=1
    and [新加GUID列的临时表] not in (select top 50 [新加GUID列的临时表]
    from #result
    order by [新加GUID列的临时表] desc)
    and [新加GUID列的临时表] not in (select top 50 [新加GUID列的临时表]
    from #result
    order by [新加GUID列的临时表])
    ) [新加GUID列的临时表],(
    select avg([页压缩临时表]) [页压缩临时表]
    from #result
    where 1=1
    and [页压缩临时表] not in (select top 50 [页压缩临时表]
    from #result
    order by [页压缩临时表] desc)
    and [页压缩临时表] not in (select top 50 [页压缩临时表]
    from #result
    order by [页压缩临时表])
    ) [页压缩临时表],
    (
    select avg([行压缩临时表+新加GUID列]) [行压缩临时表+新加GUID列]
    from #result
    where 1=1
    and [行压缩临时表+新加GUID列] not in (select top 50 [行压缩临时表+新加GUID列]
    from #result
    order by [行压缩临时表+新加GUID列] desc)
    and [行压缩临时表+新加GUID列] not in (select top 50 [行压缩临时表+新加GUID列]
    from #result
    order by [行压缩临时表+新加GUID列])
    ) [行压缩临时表+新加GUID列],
    (
    select avg([页压缩临时表+新加GUID列]) [页压缩临时表+新加GUID列]
    from #result
    where 1=1
    and [页压缩临时表+新加GUID列] not in (select top 50 [页压缩临时表+新加GUID列]
    from #result
    order by [页压缩临时表+新加GUID列] desc)
    and [页压缩临时表+新加GUID列] not in (select top 50 [页压缩临时表+新加GUID列]
    from #result
    order by [页压缩临时表+新加GUID列])
    ) [页压缩临时表+新加GUID列],(
    select avg([新加自增列临时表]) [新加自增列临时表]
    from #result
    where 1=1
    and [新加自增列临时表] not in (select top 50 [新加自增列临时表]
    from #result
    order by [新加自增列临时表] desc)
    and [新加自增列临时表] not in (select top 50 [新加自增列临时表]
    from #result
    order by [新加自增列临时表])
    ) [新加自增列临时表]

     

     

    --------------------------------------------------------------------------------------------------------------------------------------

     

     

    结论,GUID插入数据,比自增快,INTO方式插入数据是最快的

  • 相关阅读:
    hdoj Last non-zero Digit in N! 【数论】
    spin_lock &amp; mutex_lock的差别?
    20140514,微软5月14日公布8个安全补丁
    教你用笔记本破解无线路由器password
    SSL工作原理
    MS-SQLSERVER中的MSDTC不可用解决方法
    grub2手动引导ubuntu
    用递归翻转一个栈 Reverse a stack using recursion
    腾讯面试
    AngularJS移动开发中的坑汇总
  • 原文地址:https://www.cnblogs.com/qanholas/p/2530707.html
Copyright © 2020-2023  润新知