MSSQL里报错!无法绑定由多个部分组成的标识符,access没事,
本帖最后由 hongendazhang 于 2014-01-14 12:17:07 编辑
新:
SELECT dbo.tGoods.TypeCode, dbo.tGoods.GoodsBrand, dbo.tGoods.GoodsType, dbo.tGoods.ifDisCount, dbo.tGoods.Supply, dbo.tGoods.Remark, dbo.tBill.BillID,
dbo.tBill.CustName, dbo.tBill.BillCode, dbo.tBill.AddDate, dbo.tBill.AddTime, dbo.tBill.MRemark, dbo.tBill.FUser, dbo.tBill.Maker, dbo.tBill.MakerDate, dbo.tBill.Editer,
dbo.tBill.EditDate, dbo.tBill.BillType, dbo.tBill.InOrOut, dbo.tBill.VipCode, dbo.tBill.PayType, dbo.tBill.SkMoney, dbo.tBill.ZLMoney, dbo.tBill.YSMoney,
dbo.tBill.DepotName, dbo.tBill.Field1, dbo.tBill.Field2, dbo.tBill.Field3, dbo.tBill.Field4, dbo.tBill.Field5, DATEPART(hh, dbo.tBill.AddTime) AS HJtime,
CAST(YEAR(dbo.tBill.AddDate) AS varchar(4)) + '-' + CAST(MONTH(dbo.tBill.AddDate) AS varchar(4)) AS HjMonth, DATEPART(yyyy, dbo.tBill.AddDate) AS HjYear,
DATEPART(ww, dbo.tBill.AddDate) AS WeekDate, '全部' AS AllBill, dbo.tBillDetail.BillDetailID, CAST(DATEPART(yyyy, dbo.tBill.AddDate) AS varchar(4))
+ '年' + CAST(DATEPART(q, dbo.tBill.AddDate) AS varchar(4)) + '季度' AS HjSeason, dbo.tVip.VipName, dbo.tBillDetail.BarCode, dbo.tBillDetail.DBillCode,
dbo.tBillDetail.GoodsStyle, dbo.tBillDetail.GoodsName, dbo.tBillDetail.Units, dbo.tBillDetail.SizeGroup, dbo.tBillDetail.ColorCode, dbo.tBillDetail.ColorName,
dbo.tBillDetail.ColorValue, dbo.tBillDetail.DetailField1, dbo.tBillDetail.DetailField2, dbo.tBillDetail.DetailField3, dbo.tBillDetail.DetailField4, dbo.tBillDetail.DetailField5,
dbo.tBillDetail.SizeCode, dbo.tBillDetail.SizeName, dbo.tBillDetail.Number AS Number1, dbo.tBillDetail.Money AS Money1, dbo.tBillDetail.InMoney AS InMoney1,
(CASE WHEN tBill.BillType IN ('销售出货', '销售退货') THEN tBillDetail.Number * tBillDetail.Sign * - 1 ELSE tBillDetail.Number * tBillDetail.Sign END) AS Number,
dbo.tBillDetail.Discount, dbo.tBillDetail.Price, (CASE WHEN tBill.BillType IN ('销售出货', '销售退货')
THEN tBillDetail.Money * tBillDetail.Sign * - 1 ELSE tBillDetail.Money * tBillDetail.Sign END) AS Money, dbo.tBillDetail.colPosition, dbo.tBillDetail.rowPosition,
dbo.tBillDetail.DRemark, dbo.tBillDetail.Sign, dbo.tBillDetail.InPrice, (CASE WHEN tBill.BillType IN ('销售出货', '销售退货')
THEN tBillDetail.InPrice * tBillDetail.Number * tBillDetail.Sign * - 1 ELSE tBillDetail.InPrice * tBillDetail.Number * tBillDetail.Sign END) AS InMoney,
dbo.tGoods.dpPrice, dbo.tGoods.xsPrice, dbo.tGoods.GoodsSeason, dbo.tGoods.DepotUp, dbo.tGoods.DepotDown
FROM dbo.tBill LEFT OUTER JOIN
dbo.tBillDetail LEFT OUTER JOIN
dbo.tGoods ON dbo.tBillDetail.GoodsStyle = dbo.tGoods.GoodsStyle ON dbo.tBill.BillCode = dbo.tBillDetail.DBillCode LEFT OUTER JOIN
dbo.tVip ON dbo.tBill.VipCode = dbo.tVip.VipCode
UNION ALL
SELECT tGoods_1.TypeCode, tGoods_1.GoodsBrand, tGoods_1.GoodsType, tGoods_1.ifDisCount, tGoods_1.Supply, tGoods_1.Remark, tBill_1.BillID, tBill_1.DepotName,
tBill_1.BillCode, tBill_1.AddDate, tBill_1.AddTime, tBill_1.MRemark, tBill_1.FUser, tBill_1.Maker, tBill_1.MakerDate, tBill_1.Editer, tBill_1.EditDate, tBill_1.BillType,
tBill_1.InOrOut, tBill_1.VipCode, tBill_1.PayType, tBill_1.SkMoney, tBill_1.ZLMoney, tBill_1.YSMoney, tBill_1.CustName, tBill_1.Field1, tBill_1.Field2, tBill_1.Field3,
tBill_1.Field4, tBill_1.Field5, DATEPART(hh, tBill_1.AddTime) AS HjTime, CAST(YEAR(tBill_1.AddDate) AS varchar(4)) + '-' + CAST(MONTH(tBill_1.AddDate) AS varchar(4))
AS HjMonth, DATEPART(yyyy, tBill_1.AddDate) AS HjYear, DATEPART(ww, tBill_1.AddDate) AS WeekDate, '全部' AS AllBill, tBillDetail_1.BillDetailID,
CAST(DATEPART(yyyy, tBill_1.AddDate) AS varchar(4)) + '年' + CAST(DATEPART(q, tBill_1.AddDate) AS varchar(4)) + '季度' AS HjSeason, tVip_1.VipName,
tBillDetail_1.BarCode, tBillDetail_1.DBillCode, tBillDetail_1.GoodsStyle, tBillDetail_1.GoodsName, tBillDetail_1.Units, tBillDetail_1.SizeGroup,
tBillDetail_1.ColorCode, tBillDetail_1.ColorName, tBillDetail_1.ColorValue, tBillDetail_1.DetailField1, tBillDetail_1.DetailField2, tBillDetail_1.DetailField3,
tBillDetail_1.DetailField4, tBillDetail_1.DetailField5, tBillDetail_1.SizeCode, tBillDetail_1.SizeName, tBillDetail_1.Number AS Number1,
tBillDetail_1.Money AS Money1, tBillDetail_1.InMoney AS InMoney1, (CASE WHEN tBill.BillType IN ('销售出货', '销售退货')
THEN tBillDetail.Number * 1 * - 1 ELSE tBillDetail.Number * 1 END) AS Number, tBillDetail_1.Discount, tBillDetail_1.Price, (CASE WHEN tBill.BillType IN ('销售出货',
'销售退货') THEN tBillDetail.Money * 1 * - 1 ELSE tBillDetail.Money * 1 END) AS Money, tBillDetail_1.colPosition, tBillDetail_1.rowPosition, tBillDetail_1.DRemark,
1 AS Expr1, tBillDetail_1.InPrice, (CASE WHEN tBill.BillType IN ('销售出货', '销售退货')
THEN tBillDetail.InPrice * tBillDetail.Number * 1 * - 1 ELSE tBillDetail.InPrice * tBillDetail.Number * 1 END) AS InMoney, tGoods_1.dpPrice, tGoods_1.xsPrice,
tGoods_1.GoodsSeason, tGoods_1.DepotUp, tGoods_1.DepotDown
FROM dbo.tBill AS tBill_1 LEFT OUTER JOIN
dbo.tBillDetail AS tBillDetail_1 LEFT OUTER JOIN
dbo.tGoods AS tGoods_1 ON tBillDetail_1.GoodsStyle = tGoods_1.GoodsStyle ON tBill_1.BillCode = tBillDetail_1.DBillCode LEFT OUTER JOIN
dbo.tVip AS tVip_1 ON tBill_1.VipCode = tVip_1.VipCode
WHERE (tBill_1.BillType = '店铺调拨')
SELECT dbo.tGoods.TypeCode, dbo.tGoods.GoodsBrand, dbo.tGoods.GoodsType, dbo.tGoods.ifDisCount, dbo.tGoods.Supply, dbo.tGoods.Remark, dbo.tBill.BillID,
dbo.tBill.CustName, dbo.tBill.BillCode, dbo.tBill.AddDate, dbo.tBill.AddTime, dbo.tBill.MRemark, dbo.tBill.FUser, dbo.tBill.Maker, dbo.tBill.MakerDate, dbo.tBill.Editer,
dbo.tBill.EditDate, dbo.tBill.BillType, dbo.tBill.InOrOut, dbo.tBill.VipCode, dbo.tBill.PayType, dbo.tBill.SkMoney, dbo.tBill.ZLMoney, dbo.tBill.YSMoney,
dbo.tBill.DepotName, dbo.tBill.Field1, dbo.tBill.Field2, dbo.tBill.Field3, dbo.tBill.Field4, dbo.tBill.Field5, DATEPART(hh, dbo.tBill.AddTime) AS HJtime,
CAST(YEAR(dbo.tBill.AddDate) AS varchar(4)) + '-' + CAST(MONTH(dbo.tBill.AddDate) AS varchar(4)) AS HjMonth, DATEPART(yyyy, dbo.tBill.AddDate) AS HjYear,
DATEPART(ww, dbo.tBill.AddDate) AS WeekDate, '全部' AS AllBill, dbo.tBillDetail.BillDetailID, CAST(DATEPART(yyyy, dbo.tBill.AddDate) AS varchar(4))
+ '年' + CAST(DATEPART(q, dbo.tBill.AddDate) AS varchar(4)) + '季度' AS HjSeason, dbo.tVip.VipName, dbo.tBillDetail.BarCode, dbo.tBillDetail.DBillCode,
dbo.tBillDetail.GoodsStyle, dbo.tBillDetail.GoodsName, dbo.tBillDetail.Units, dbo.tBillDetail.SizeGroup, dbo.tBillDetail.ColorCode, dbo.tBillDetail.ColorName,
dbo.tBillDetail.ColorValue, dbo.tBillDetail.DetailField1, dbo.tBillDetail.DetailField2, dbo.tBillDetail.DetailField3, dbo.tBillDetail.DetailField4, dbo.tBillDetail.DetailField5,
dbo.tBillDetail.SizeCode, dbo.tBillDetail.SizeName, dbo.tBillDetail.Number AS Number1, dbo.tBillDetail.Money AS Money1, dbo.tBillDetail.InMoney AS InMoney1,
(CASE WHEN tBill.BillType IN ('销售出货', '销售退货') THEN tBillDetail.Number * tBillDetail.Sign * - 1 ELSE tBillDetail.Number * tBillDetail.Sign END) AS Number,
dbo.tBillDetail.Discount, dbo.tBillDetail.Price, (CASE WHEN tBill.BillType IN ('销售出货', '销售退货')
THEN tBillDetail.Money * tBillDetail.Sign * - 1 ELSE tBillDetail.Money * tBillDetail.Sign END) AS Money, dbo.tBillDetail.colPosition, dbo.tBillDetail.rowPosition,
dbo.tBillDetail.DRemark, dbo.tBillDetail.Sign, dbo.tBillDetail.InPrice, (CASE WHEN tBill.BillType IN ('销售出货', '销售退货')
THEN tBillDetail.InPrice * tBillDetail.Number * tBillDetail.Sign * - 1 ELSE tBillDetail.InPrice * tBillDetail.Number * tBillDetail.Sign END) AS InMoney,
dbo.tGoods.dpPrice, dbo.tGoods.xsPrice, dbo.tGoods.GoodsSeason, dbo.tGoods.DepotUp, dbo.tGoods.DepotDown
FROM dbo.tBill LEFT OUTER JOIN
dbo.tBillDetail LEFT OUTER JOIN
dbo.tGoods ON dbo.tBillDetail.GoodsStyle = dbo.tGoods.GoodsStyle ON dbo.tBill.BillCode = dbo.tBillDetail.DBillCode LEFT OUTER JOIN
dbo.tVip ON dbo.tBill.VipCode = dbo.tVip.VipCode
SELECT tGoods_1.TypeCode, tGoods_1.GoodsBrand, tGoods_1.GoodsType, tGoods_1.ifDisCount, tGoods_1.Supply, tGoods_1.Remark, tBill_1.BillID, tBill_1.DepotName,
tBill_1.BillCode, tBill_1.AddDate, tBill_1.AddTime, tBill_1.MRemark, tBill_1.FUser, tBill_1.Maker, tBill_1.MakerDate, tBill_1.Editer, tBill_1.EditDate, tBill_1.BillType,
tBill_1.InOrOut, tBill_1.VipCode, tBill_1.PayType, tBill_1.SkMoney, tBill_1.ZLMoney, tBill_1.YSMoney, tBill_1.CustName, tBill_1.Field1, tBill_1.Field2, tBill_1.Field3,
tBill_1.Field4, tBill_1.Field5, DATEPART(hh, tBill_1.AddTime) AS HjTime, CAST(YEAR(tBill_1.AddDate) AS varchar(4)) + '-' + CAST(MONTH(tBill_1.AddDate) AS varchar(4))
AS HjMonth, DATEPART(yyyy, tBill_1.AddDate) AS HjYear, DATEPART(ww, tBill_1.AddDate) AS WeekDate, '全部' AS AllBill, tBillDetail_1.BillDetailID,
CAST(DATEPART(yyyy, tBill_1.AddDate) AS varchar(4)) + '年' + CAST(DATEPART(q, tBill_1.AddDate) AS varchar(4)) + '季度' AS HjSeason, tVip_1.VipName,
tBillDetail_1.BarCode, tBillDetail_1.DBillCode, tBillDetail_1.GoodsStyle, tBillDetail_1.GoodsName, tBillDetail_1.Units, tBillDetail_1.SizeGroup,
tBillDetail_1.ColorCode, tBillDetail_1.ColorName, tBillDetail_1.ColorValue, tBillDetail_1.DetailField1, tBillDetail_1.DetailField2, tBillDetail_1.DetailField3,
tBillDetail_1.DetailField4, tBillDetail_1.DetailField5, tBillDetail_1.SizeCode, tBillDetail_1.SizeName, tBillDetail_1.Number AS Number1,
tBillDetail_1.Money AS Money1, tBillDetail_1.InMoney AS InMoney1, (CASE WHEN tBill.BillType IN ('销售出货', '销售退货')
THEN tBillDetail.Number * 1 * - 1 ELSE tBillDetail.Number * 1 END) AS Number, tBillDetail_1.Discount, tBillDetail_1.Price, (CASE WHEN tBill.BillType IN ('销售出货',
'销售退货') THEN tBillDetail.Money * 1 * - 1 ELSE tBillDetail.Money * 1 END) AS Money, tBillDetail_1.colPosition, tBillDetail_1.rowPosition, tBillDetail_1.DRemark,
1 AS Expr1, tBillDetail_1.InPrice, (CASE WHEN tBill.BillType IN ('销售出货', '销售退货')
THEN tBillDetail.InPrice * tBillDetail.Number * 1 * - 1 ELSE tBillDetail.InPrice * tBillDetail.Number * 1 END) AS InMoney, tGoods_1.dpPrice, tGoods_1.xsPrice,
tGoods_1.GoodsSeason, tGoods_1.DepotUp, tGoods_1.DepotDown
FROM dbo.tBill AS tBill_1 LEFT OUTER JOIN
dbo.tBillDetail AS tBillDetail_1 LEFT OUTER JOIN
dbo.tGoods AS tGoods_1 ON tBillDetail_1.GoodsStyle = tGoods_1.GoodsStyle ON tBill_1.BillCode = tBillDetail_1.DBillCode LEFT OUTER JOIN
dbo.tVip AS tVip_1 ON tBill_1.VipCode = tVip_1.VipCode
WHERE (tBill_1.BillType = '店铺调拨')
SELECT dbo.tGoods.TypeCode ,
dbo.tGoods.GoodsBrand ,
dbo.tGoods.GoodsType ,
dbo.tGoods.ifDisCount ,
dbo.tGoods.Supply ,
dbo.tGoods.Remark ,
dbo.tBill.BillID ,
dbo.tBill.CustName ,
dbo.tBill.BillCode ,
dbo.tBill.AddDate ,
dbo.tBill.AddTime ,
dbo.tBill.MRemark ,
dbo.tBill.FUser ,
dbo.tBill.Maker ,
dbo.tBill.MakerDate ,
dbo.tBill.Editer ,
dbo.tBill.EditDate ,
dbo.tBill.BillType ,
dbo.tBill.InOrOut ,
dbo.tBill.VipCode ,
dbo.tBill.PayType ,
dbo.tBill.SkMoney ,
dbo.tBill.ZLMoney ,
dbo.tBill.YSMoney ,
dbo.tBill.DepotName ,
dbo.tBill.Field1 ,
dbo.tBill.Field2 ,
dbo.tBill.Field3 ,
dbo.tBill.Field4 ,
dbo.tBill.Field5 ,
DATEPART(hh, dbo.tBill.AddTime) AS HJtime ,
CAST(YEAR(dbo.tBill.AddDate) AS VARCHAR(4)) + '-'
+ CAST(MONTH(dbo.tBill.AddDate) AS VARCHAR(4)) AS HjMonth ,
DATEPART(yyyy, dbo.tBill.AddDate) AS HjYear ,
DATEPART(ww, dbo.tBill.AddDate) AS WeekDate ,
'全部' AS AllBill ,
dbo.tBillDetail.BillDetailID ,
CAST(DATEPART(yyyy, dbo.tBill.AddDate) AS VARCHAR(4)) + '年'
+ CAST(DATEPART(q, dbo.tBill.AddDate) AS VARCHAR(4)) + '季度' AS HjSeason ,
dbo.tVip.VipName ,
dbo.tBillDetail.BarCode ,
dbo.tBillDetail.DBillCode ,
dbo.tBillDetail.GoodsStyle ,
dbo.tBillDetail.GoodsName ,
dbo.tBillDetail.Units ,
dbo.tBillDetail.SizeGroup ,
dbo.tBillDetail.ColorCode ,
dbo.tBillDetail.ColorName ,
dbo.tBillDetail.ColorValue ,
dbo.tBillDetail.DetailField1 ,
dbo.tBillDetail.DetailField2 ,
dbo.tBillDetail.DetailField3 ,
dbo.tBillDetail.DetailField4 ,
dbo.tBillDetail.DetailField5 ,
dbo.tBillDetail.SizeCode ,
dbo.tBillDetail.SizeName ,
dbo.tBillDetail.Number AS Number1 ,
dbo.tBillDetail.Money AS Money1 ,
dbo.tBillDetail.InMoney AS InMoney1 ,
( CASE WHEN tBill.BillType IN ( '销售出货', '销售退货' )
THEN tBillDetail.Number * tBillDetail.Sign * -1
ELSE tBillDetail.Number * tBillDetail.Sign
END ) AS Number ,
dbo.tBillDetail.Discount ,
dbo.tBillDetail.Price ,
( CASE WHEN tBill.BillType IN ( '销售出货', '销售退货' )
THEN tBillDetail.Money * tBillDetail.Sign * -1
ELSE tBillDetail.Money * tBillDetail.Sign
END ) AS Money ,
dbo.tBillDetail.colPosition ,
dbo.tBillDetail.rowPosition ,
dbo.tBillDetail.DRemark ,
dbo.tBillDetail.Sign ,
dbo.tBillDetail.InPrice ,
( CASE WHEN tBill.BillType IN ( '销售出货', '销售退货' )
THEN tBillDetail.InPrice * tBillDetail.Number
* tBillDetail.Sign * -1
ELSE tBillDetail.InPrice * tBillDetail.Number
* tBillDetail.Sign
END ) AS InMoney ,
dbo.tGoods.dpPrice ,
dbo.tGoods.xsPrice ,
dbo.tGoods.GoodsSeason ,
dbo.tGoods.DepotUp ,
dbo.tGoods.DepotDown
FROM dbo.tBill
LEFT OUTER JOIN dbo.tBillDetail
LEFT OUTER JOIN dbo.tGoods ON dbo.tBillDetail.GoodsStyle = dbo.tGoods.GoodsStyle ON dbo.tBill.BillCode = dbo.tBillDetail.DBillCode
LEFT OUTER JOIN dbo.tVip ON dbo.tBill.VipCode = dbo.tVip.VipCode
UNION ALL
SELECT tGoods_1.TypeCode ,
tGoods_1.GoodsBrand ,
tGoods_1.GoodsType ,
tGoods_1.ifDisCount ,
tGoods_1.Supply ,
tGoods_1.Remark ,
tBill_1.BillID ,
tBill_1.DepotName ,
tBill_1.BillCode ,
tBill_1.AddDate ,
tBill_1.AddTime ,
tBill_1.MRemark ,
tBill_1.FUser ,
tBill_1.Maker ,
tBill_1.MakerDate ,
tBill_1.Editer ,
tBill_1.EditDate ,
tBill_1.BillType ,
tBill_1.InOrOut ,
tBill_1.VipCode ,
tBill_1.PayType ,
tBill_1.SkMoney ,
tBill_1.ZLMoney ,
tBill_1.YSMoney ,
tBill_1.CustName ,
tBill_1.Field1 ,
tBill_1.Field2 ,
tBill_1.Field3 ,
tBill_1.Field4 ,
tBill_1.Field5 ,
DATEPART(hh, tBill_1.AddTime) AS HjTime ,
CAST(YEAR(tBill_1.AddDate) AS VARCHAR(4)) + '-'
+ CAST(MONTH(tBill_1.AddDate) AS VARCHAR(4)) AS HjMonth ,
DATEPART(yyyy, tBill_1.AddDate) AS HjYear ,
DATEPART(ww, tBill_1.AddDate) AS WeekDate ,
'全部' AS AllBill ,
tBillDetail_1.BillDetailID ,
CAST(DATEPART(yyyy, tBill_1.AddDate) AS VARCHAR(4)) + '年'
+ CAST(DATEPART(q, tBill_1.AddDate) AS VARCHAR(4)) + '季度' AS HjSeason ,
tVip_1.VipName ,
tBillDetail_1.BarCode ,
tBillDetail_1.DBillCode ,
tBillDetail_1.GoodsStyle ,
tBillDetail_1.GoodsName ,
tBillDetail_1.Units ,
tBillDetail_1.SizeGroup ,
tBillDetail_1.ColorCode ,
tBillDetail_1.ColorName ,
tBillDetail_1.ColorValue ,
tBillDetail_1.DetailField1 ,
tBillDetail_1.DetailField2 ,
tBillDetail_1.DetailField3 ,
tBillDetail_1.DetailField4 ,
tBillDetail_1.DetailField5 ,
tBillDetail_1.SizeCode ,
tBillDetail_1.SizeName ,
tBillDetail_1.Number AS Number1 ,
tBillDetail_1.Money AS Money1 ,
tBillDetail_1.InMoney AS InMoney1 ,
( CASE WHEN tBill.BillType IN ( '销售出货', '销售退货' )
THEN tBillDetail.Number * 1 * -1
ELSE tBillDetail.Number * 1
END ) AS Number ,
tBillDetail_1.Discount ,
tBillDetail_1.Price ,
( CASE WHEN tBill.BillType IN ( '销售出货', '销售退货' )
THEN tBillDetail.Money * 1 * -1
ELSE tBillDetail.Money * 1
END ) AS Money ,
tBillDetail_1.colPosition ,
tBillDetail_1.rowPosition ,
tBillDetail_1.DRemark ,
1 AS Expr1 ,
tBillDetail_1.InPrice ,
( CASE WHEN tBill.BillType IN ( '销售出货', '销售退货' )
THEN tBillDetail.InPrice * tBillDetail.Number * 1 * -1
ELSE tBillDetail.InPrice * tBillDetail.Number * 1
END ) AS InMoney ,
tGoods_1.dpPrice ,
tGoods_1.xsPrice ,
tGoods_1.GoodsSeason ,
tGoods_1.DepotUp ,
tGoods_1.DepotDown
FROM dbo.tBill AS tBill_1
LEFT OUTER JOIN dbo.tBillDetail AS tBillDetail_1
LEFT OUTER JOIN dbo.tGoods AS tGoods_1 ON tBillDetail_1.GoodsStyle = tGoods_1.GoodsStyle ON tBill_1.BillCode = tBillDetail_1.DBillCode
LEFT OUTER JOIN dbo.tVip AS tVip_1 ON tBill_1.VipCode = tVip_1.VipCode
WHERE ( tBill_1.BillType = '店铺调拨' )