select isnull(convert(numeric(10,2), round(convert(numeric(10,0),x.ocr_file_num)/x.file_num * 100,2)),0)
where tr_date>= '2012-03-31' and tr_date <='2012-03-31')x
numeric(10,0) 10位數(shù)字 小數(shù)點(diǎn)后0位 ;
convert(numeric(10,0),x.ocr_file_num) 把x.ocr_file_num 轉(zhuǎn)為小數(shù)點(diǎn)后0位的10位數(shù)字;
round(a,b) 保留數(shù)字a小數(shù)點(diǎn)后b位小數(shù);
select x.imp_type imp_type,isnull(y.un_auidted_num,0) un_auidted_num from
(select imp_type from imp_audit_type noholdlock where disp_sign=0 and tree_type=0 )x,(select imp_type,count(1) as un_auidted_num from imp_result noholdlock where 1=1
group by imp_type)y
noholdlock where x.imp_type *= y.imp_type order by x.imp_type
等價(jià)于
select x.imp_type imp_type,isnull(y.un_auidted_num,0) un_auidted_num from
(select imp_type from imp_audit_type noholdlock where disp_sign=0 and tree_type=0 )x left join (select imp_type,count(1) as un_auidted_num from imp_result noholdlock where 1=1
group by imp_type)y
noholdlock on x.imp_type = y.imp_type order by x.imp_type
where x.imp_type *= y.imp_type order by x.imp_type 相當(dāng)于使用join的on條件;
通過(guò)在 select 或 readtext 命令中將 holdlock、noholdlock 和 shared 選項(xiàng)應(yīng)用到單個(gè)表來(lái)替換某個(gè)會(huì)話的鎖定級(jí)別:
使用級(jí)別 關(guān)鍵字 作用
1 noholdlock 直到事務(wù)結(jié)束再持有鎖;在級(jí)別 3 使用以強(qiáng)制執(zhí)行級(jí)別 1
2, 3 holdlock 持有共享鎖直到事務(wù)完成;在級(jí)別 1使用以強(qiáng)制執(zhí)行級(jí)別 3
無(wú) shared 在為更新操作打開(kāi)游標(biāo)時(shí),對(duì) select語(yǔ)句應(yīng)用共享鎖而非更新鎖
批處理:
bcp db..ds_aptr in f:/ftproot/dataSource/20120418\ABIS-APTR-1G-20120418 -e E:\DataManager\error\ds_aptr20120418.txt -c -t"|!" -r"\n" -Uad -Shn -Pbj -Jcp936 -b10000
ds_aptr數(shù)據(jù)表 in導(dǎo)入 f:/ftproot/dataSource/20120418\ABIS-APTR-1G-20120418
-e E:\DataManager\error\ds_aptr20120418.txt 錯(cuò)誤日志
-t"|!" 以|!為列的分隔符
-r"\n" 以\n為一條數(shù)據(jù)的分隔符
-Uad 用戶名ad
-Shn 服務(wù)器hn
-Pbj 密碼bj
-Jcp936 編碼cp936
-b10000 分批10000條提交