1、SQL去掉字符串左侧0
replace(ltrim(replace(“WERKS”,‘0’,’ ‘)),’ ',‘0’);
2、exists用法
–exists判断引导的子句是否有结果集返回,有返回结果集条件成立,反之,不成立;
–判断A表对应字段的数据在C表中是否存在
EXISTS (SELECT 1 FROM TABLE01 AS C WHERE A.SAP_DATE=C.YEAR||C.MONTH AND A.MATNR=C.MATNR)
3、补零:select ‘37111’|| abap_alphanum(‘0’,(7-length(‘’)37111))-1) from dummy
4、查询BW系统正在执行的sql:
Select now() as cur_times,t.statement_string,—执行语句
t.statement_status,–执行状态
round(t.allocated_memory_size/1024/1024/1024,2)||’G’ as allocated_memory,–分配内存
t.connection_id,c.client_host,t.host,t.port,t.last_executed_time,t.last_action_time,
t.compiled_time
from m_active_statements t
left join m_connections c
on t.connection_id=c.connection_id
order by t.last_executed_time asc
5、取消进程:
Alter system cancel session 123456 ;