下面说一下单价版升迁网络版应该修改的地方:
1,日期字段:应将 #日期# 替换为 '日期'
2,取当前时间函数应将 date() 换为 getdate(),但应注意的是 getdate()函数返回的是日期+时间,如果只取日期值,应用 left(getdate(),10)
3,update语句如果涉及多个表格 ,应将单机版语句
update 表1 inner join 表2 on 表1.关联字段=表2. 关联字段 set ....
替换为
update 表1 set 表1.字段=... from 表1,表2 where 表1.关联字段=表2.关联字段
4,网络版应使用单引号包含文本,而不能使用双引号
即 应使用 select * from 表 where 字段='abc'
而不能用 select * from 表 where 字段="abc"
5,网络版删除记录应用
delete from 表 where ...
不能用
delete * from 表
6, 网络版不能用iif 用 case when then
例如:单机版:select iif (A.ID is null,'0001',right ('1000'& A.ID,4)) as 编号
from (select max (right(客户编号,4))+1 as ID
from 钟点工客户 ) as A
网络版:select (case when a.id is null then '0001' else right ('1000'+ a.id,4) end ) as 编号
from (select max (right(客户编号,4))+1 as id
from 钟点工客户 ) as a
---------------------------------------------------------------------------------------------------------------------------------
带日期自动单号:
select cast(year(getdate()) as varchar(4))+ right(100+month(getdate()),2)+
right(100 +day(getdate()),2)+
right(str(10000+(case when A.ID is null then '1' else A.ID end)),4) as 接待编号
from (select cast(right(max(接待编号),10) as int)+1 as ID from 接待登记表
where left(接待编号,8)=cast(year(getdate()) as varchar(4))+
right('0'+cast(month(getdate()) as varchar(2)),2)+
right('0' + cast(day(getdate()) as varchar(2)),2)) as A
自动生成字母连接日期单号:
select 'QX' + cast (year(getdate()) as varchar(4))+right(100+month(getdate()),2)+
right(100+day(getdate()),2)+
right(str(1000+(case when A.ID is null then '1' else A.ID end)),3) as 缺陷记录编号
from (select cast(right(max(缺陷记录编号),8) as int)+1 as ID from 缺陷通知
where right(left(缺陷记录编号,10),8)=cast(year(getdate()) as varchar(4))+
right('0'+cast(month(getdate()) as varchar(2)),2)+ right('0' +
cast(day(getdate()) as varchar(2)),2)) as A
不带日期的编号:
SELECT right(str(100000000 + (case when A.ID is null then '1' else A.ID end)),7)
AS 编号 FROM (SELECT max((right(车辆买费.编号,7)))+1 as ID
FROM 车辆买费) AS A
7.自动生成编号 select 'GZ' + cast (year(getdate()) as varchar(4))+right(100+month(getdate()),2)+
right(100+day(getdate()),2)+
right(str(1000+(case when A.ID is null then '1' else A.ID end)),3) as 收款编号
from (select cast(right(max(收款编号),8) as int)+1 as ID from 财务收款
where right(left(收款编号,10),8)=cast(year(getdate()) as varchar(4))+right('0'+cast(month(getdate()) as varchar(2)),2)+ right('0' + cast(day(getdate()) as varchar(2)),2)) as A
8.有中间表的
7, 库存
单机版:
delete from 临时表
go
insert into 临时表
select 备件入库.备件编号,sum(备件入库.入库数量) as 数量
from 备件入库
group by 备件入库.备件编号
go
update 备件库存 set 备件库存.入库数量=临时表.数量 from 备件库存,临时表 where 临时表.备件编号=备件库存.备件编号
网络版:
update 备件库存 set 备件库存.入库数量=临时表.数量 from 备件库存,(select 备件入库.备件编号,sum(备件入库.入库数量) as 数量
from 备件入库
group by 备件入库.备件编号) as 临时表 where 临时表.备件编号=备件库存.备件编号
update 备件库存 set 备件库存.入库数量=临时表.数量 from 备件库存,
(select 备件入库.备件编号,sum(备件入库.入库数量) as 数量
from 备件入库
group by 备件入库.备件编号) as 临时表 where 临时表.备件编号=备件库存.备件编号
(select 备件入库.备件编号,sum(备件入库.入库数量) as 数量
from 备件入库
group by 备件入库.备件编号) as 临时表
7.网络验证为空 select 1 where :字段 is null or :字段=''
8.网络计算总金额
select (case when sum(金额) is null then 0 else sum(金额) end ) as 发货总额
from 发货登记从表
where 发货编号=':发货编号'.
SELECT cast(year(':入库日期') as varchar(4))+right(100 +
month(':入库日期'),2)+right(100 + day(':入库日期'),2)+right(str(10000 +
(case when A.ID is null then '1' else A.ID end)),3) AS 入库单号 FROM
(SELECT max((right(入库单号,3)))+1 as ID FROM 材料入库单
where 入库日期=':入库日期') AS A
select 'F'& year(date())&right(('0'&month(date())),2)&right(('0'&day(date())),2)&
right(val(1000+("001"&A.ID)),3) as 案件编号
from(select max(right(案件编号,10))+1 as ID from 来访登记 where 建档日期 =date())as A
SELECT 'X' & year(#:建档日期#) & right('0' & month(#:建档日期#),2) & iif(A.ID is null,'0001',
right('0000' & A.ID,4)) AS 案件编号
FROM (SELECT MAX(right((来访登记.案件编号),4))+1 AS ID FROM 来访登记
where year(建档日期)=year(#:建档日期#) and month(建档日期)=month(#:建档日期#)
AND 案件编号 like 'X%') AS A
select ID,花店编号,店名,批发日期,批发金额,实付金额,批发欠款,清账日期,是否清账
from 批发登记
where 店名 LIKE '%:店名%' and 批发欠款 >0 and 批发日期 between ':起始日期' and ':截止日期'
union all
select null, '合计',null,null,sum(批发金额),sum(实付金额),sum(批发欠款),null,null
FROM 批发登记
where 店名 LIKE '%:店名%' and 批发欠款 >0 and 批发日期 between ':起始日期' and ':截止日期'
delete from 补交
go
insert into 补交
select 病历号,sum(补交金额) as 补交金额
from 补交费用
where 补交费用.病历号=':病历号'
group by 病历号
go
update 患者信息 inner Join 补交 on 患者信息.病历号=补交.病历号
set 患者信息.补交金额=补交.补交金额
go
update 患者信息 set 欠付款=总消费额-已付款-补交金额
where 患者信息.病历号=':病历号'
select 操作者 from 高级用户 WHERE 操作者=@^CurUser() or :ID is null 从表修改 select 操作者 from 高级用户 WHERE 操作者=@^CurUser() 从表删除
验证数量:
select 1 where :退书册数 > :领书册数