1、變量表:

創(chuàng)新互聯(lián)建站-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價(jià)比周至網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式周至網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋周至地區(qū)。費(fèi)用合理售后完善,十余年實(shí)體公司更值得信賴。
declare @SDT datetime,@EDT datetime --定義執(zhí)行開始、結(jié)束時(shí)間
set @SDT=getdate()
--定義變量表
declare @t table
(
ID int,
Myfield nvarchar(50),
InputDT datetime
)
--插入數(shù)據(jù)到變量表
insert @t select top 10000 ID,Myfield,getdate() from 表
set @EDT=getdate()
select DATEDIFF(ms,@SDT,@EDT) AS Diffms --開始、結(jié)束時(shí)間間隔2、臨時(shí)表
declare @SDT datetime,@EDT datetime
set @SDT=getdate()
--創(chuàng)建臨時(shí)表:
create table #t
(
ID int,
Myfield nvarchar(50),
InputDT datetime
)
insert #t select top 10000 ID,Myfield,getdate() from 表
select * from #t
set @EDT=getdate()
select DATEDIFF(ms,@SDT,@EDT) AS DiffNS
drop table #t不創(chuàng)建臨時(shí)表直接插入
declare @SDT datetime,@EDT datetime
set @SDT=getdate()
select top 10000 ID,Myfield,getdate() into #t from 表
select * from #t
set @EDT=getdate()
select DATEDIFF(ms,@SDT,@EDT) AS DiffNS
drop table #t總結(jié):數(shù)據(jù)量少的時(shí)[總行數(shù)小于1000],使用變量表
數(shù)據(jù)量大時(shí)(行數(shù)>10萬),使用創(chuàng)建臨時(shí)表再插入。
數(shù)據(jù)量一般時(shí)(10萬>行數(shù)>1萬),使用不建立臨時(shí)表直接插入。
以上測(cè)試在各機(jī)器上結(jié)果可能不同。
新聞標(biāo)題:SQL中的變量表和臨時(shí)表
文章地址:http://www.chinadenli.net/article34/iiejse.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作、網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)、網(wǎng)頁設(shè)計(jì)公司、網(wǎng)站策劃、網(wǎng)站營銷
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)