日期:2014-05-16  浏览次数:20858 次

SQL命令太长,怎么办?
ASP + VbScript + SQLserver

请教一下问题: 如果SQL命令太长,应该如何解决?


SQL命令如下:



select CAST(0 AS BIT),SPACE(18) as 身份证号码,
A.*,
B.dep_mess as 部门名称,
C.dep_code as 部门编码,
L.employeeid as 职员编码,
M.name       as 职员姓名,
N.sex        as 性别,
O.id_number  as 身份证号,
P.user_name   as 制单人姓名,
Q.user_name   as 审核人姓名,
R.user_name   as 鉴定人姓名, 
S.user_name   as 公司审核人  
  FROM ZhaGongGongShi A 
  LEFT JOIN department B ON A.depid=B.dep_id 
  LEFT JOIN department C ON A.depid=C.dep_id 
  LEFT JOIN employee L   ON A.zhiyuanid=L.id 
  LEFT JOIN employee M   ON A.zhiyuanid=M.id  
  LEFT JOIN employee N   ON A.zhiyuanid=N.id  
  LEFT JOIN employee O   ON A.zhiyuanid=O.id  
  LEFT JOIN user_password P   ON A.zhidanid=P.user_id 
  LEFT JOIN user_password Q   ON A.shengheid=Q.user_id 
  LEFT JOIN user_password R   ON A.jiandingid=R.user_id 
  LEFT JOIN user_password S   ON A.shengheid1=S.user_id 
  WHERE (shengheid1 is not null and pizhuengid is null and Gongshi_ty <> '来料不良损失' and Gongshi_ty <> '停工待料补贴' ) or 
        (shengheid1 is not null and pizhuengid is null and Gongshi_ty =  '来料不良损失' and jiandingid is not null ) or 
        (shengheid1 is not null and pizhuengid is null and Gongshi_ty =  '停工待料补贴' and jiandingid is not null ) 
  order by A.id 





------解决方案--------------------
可以用连接字符   sql="select * "&_
                      "from table "&_
                      " where id=1"