H
hzbl
Unregistered / Unconfirmed
GUEST, unregistred user!
有类似下列的SQL语句,需要转换成ACCESS能支持的SQL
主要问题:
1.ACCESS是否不支持变量
2.ACCESS是否不能在同一查询中连续执行两句以上如:select * from t1
Update t1 set f1 =1
3.ACCESS 是否不支持 select ... from t1,t2 left joni t3 on ...,t6
******************************
DECLARE @vMonth int
SELECT @vMonth=:Month
SELECT
s3.ContractID,
p7.Name,
s3.SignDate ConDate,
HomeNum=(CASE dataLength(ltrim(b4.Build)) When 0 THEN NULL WHEN NULL THEN NULL ELSE +ltrim(b4.Build)+"-" END +
CASE dataLength(ltrim(b4.Unit)) When 0 THEN NULL WHEN NULL THEN NULL ELSE ltrim(b4.Unit)+"-" END +
ltrim(b4.RoomNo)),
b10.Name HomeTypeName,
b4.Acreage AppAcreage,
s3.PerMoney,
b.Acreage,
s3.TotMoney,
p14.Name PaymentName,
p18.Name WorkName,
s3.Introducer,
s3.comment,
b3.Name BuidingName
FROM
Sell_RealSell s3
LEFT OUTER JOIN pub_PaymentKind p14 ON s3.PaymentID=p14.ID
LEFT OUTER JOIN ( Building_Info b4
LEFT OUTER JOIN Building_Type b10 ON b4.BuildTypeID=b10.ID
LEFT OUTER JOIN building_append b ON b4.ID=b.BuildID
LEFT OUTER JOIN Building_Group b3 ON b4.BuildGroup=b3.ID
) ON s3.BuildID=b4.ID,
sell_salers s12,
sell_customs s5,
pub_Worker p18,
pub_Custom p7
WHERE
p7.ID=s5.CustomID AND
s12.ContractID=s3.ID AND
s5.ContractID=s3.ID AND
s12.SalerID=p18.ID AND
b3.ID=:BuildGroupID AND
s12.ContractType=2 AND
s5.ContractType=2 AND
(NOT (s3.Flag LIKE "无效%") OR (s3.Flag is NULL)) AND
((DATEPART(yy,s3.SignDate)*100+DATEPART(mm,s3.SignDate))=@vMonth)
ORDER BY b10.Name, s3.ContractID
主要问题:
1.ACCESS是否不支持变量
2.ACCESS是否不能在同一查询中连续执行两句以上如:select * from t1
Update t1 set f1 =1
3.ACCESS 是否不支持 select ... from t1,t2 left joni t3 on ...,t6
******************************
DECLARE @vMonth int
SELECT @vMonth=:Month
SELECT
s3.ContractID,
p7.Name,
s3.SignDate ConDate,
HomeNum=(CASE dataLength(ltrim(b4.Build)) When 0 THEN NULL WHEN NULL THEN NULL ELSE +ltrim(b4.Build)+"-" END +
CASE dataLength(ltrim(b4.Unit)) When 0 THEN NULL WHEN NULL THEN NULL ELSE ltrim(b4.Unit)+"-" END +
ltrim(b4.RoomNo)),
b10.Name HomeTypeName,
b4.Acreage AppAcreage,
s3.PerMoney,
b.Acreage,
s3.TotMoney,
p14.Name PaymentName,
p18.Name WorkName,
s3.Introducer,
s3.comment,
b3.Name BuidingName
FROM
Sell_RealSell s3
LEFT OUTER JOIN pub_PaymentKind p14 ON s3.PaymentID=p14.ID
LEFT OUTER JOIN ( Building_Info b4
LEFT OUTER JOIN Building_Type b10 ON b4.BuildTypeID=b10.ID
LEFT OUTER JOIN building_append b ON b4.ID=b.BuildID
LEFT OUTER JOIN Building_Group b3 ON b4.BuildGroup=b3.ID
) ON s3.BuildID=b4.ID,
sell_salers s12,
sell_customs s5,
pub_Worker p18,
pub_Custom p7
WHERE
p7.ID=s5.CustomID AND
s12.ContractID=s3.ID AND
s5.ContractID=s3.ID AND
s12.SalerID=p18.ID AND
b3.ID=:BuildGroupID AND
s12.ContractType=2 AND
s5.ContractType=2 AND
(NOT (s3.Flag LIKE "无效%") OR (s3.Flag is NULL)) AND
((DATEPART(yy,s3.SignDate)*100+DATEPART(mm,s3.SignDate))=@vMonth)
ORDER BY b10.Name, s3.ContractID