select isnull(convert(numeric(10,2), round(convert(numeric(10,0),x.ocr_file_num)/x.file_num * 100,2)),0)
from (select sum(total_file_num) as file_num,sum(auto_file_num) as ocr_file_num
from ws_ocr_report noholdlock
where tr_date>= '2012-03-31' and tr_date <='2012-03-31')x
numeric(10,0) 10位数字 小数点后0位 ;
convert(numeric(10,0),x.ocr_file_num) 把x.ocr_file_num 转为小数点后0位的10位数字;
round(a,b) 保留数字a小数点后b位小数;
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
等价于
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 相当于使用join的on条件;
通过在 select 或 readtext 命令中将 holdlock、noholdlock 和 shared 选项应用到单个表来替换某个会话的锁定级别:
使用级别 关键字 作用
1 noholdlock 直到事务结束再持有锁;在级别 3 使用以强制执行级别 1
2, 3 holdlock 持有共享锁直到事务完成;在级别 1使用以强制执行级别 3
无 shared 在为更新操作打开游标时,对 select语句应用共享锁而非更新锁
批处理:
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数据表 in导入 f:/ftproot/dataSource/20120418\ABIS-APTR-1G-20120418
-e E:\DataManager\error\ds_aptr20120418.txt 错误日志
-t"|!" 以|!为列的分隔符
-r"\n" 以\n为一条数据的分隔符
-Uad 用户名ad
-Shn 服务器hn
-Pbj 密码bj
-Jcp936 编码cp936
-b10000 分批10000条提交
posted on 2012-04-19 17:33
cuilihui 阅读(484)
评论(0) 编辑 收藏