-1
@BarId AS INTEGER
AS
BEGIN
SET NOCOUNT ON
BEGIN
select a.*, b.remark from
(
SELECT
min(bardetailid) as BarDetailId,
min(barid) as BarId,
min(Member) as Member,
min(MemberNo) as MemberNo,
min(BarMark) as BarMark,
[TypeSize] ,
min(BarLength) as BarLength,
min(BarNo) as BarNo,
min(BarTotal) as BarTotal,
[ShapeCode] ,
CAST(MAX(CAST(ShapeImage AS VARBINARY(MAX))) AS IMAGE) as ShapeImage,
CASE
WHEN c.dima <> 0 THEN
'A=' + CONVERT(varchar, cast(c.dima AS decimal(18, 0)))
ELSE ''
END +
CASE
WHEN c.dimb <> 0 THEN
', B=' + CONVERT(varchar, cast(c.dimb AS decimal(18, 0)))
ELSE ''
END +
CASE
WHEN c.dimc <> 0 THEN
', C=' + CONVERT(varchar, cast(c.dimc AS decimal(18, 0)))
ELSE ''
END +
CASE
WHEN c.dimd <> 0 THEN
', D=' + CONVERT(varchar, cast(c.dimd AS decimal(18, 0)))
ELSE ''
END +
CASE
WHEN c.dime <> 0 THEN
', E=' + CONVERT(varchar, cast(c.dime AS decimal(18, 0)))
ELSE ''
END +
CASE
WHEN c.dimf <> 0 THEN
', F=' + CONVERT(varchar, cast(c.dimf AS decimal(18, 0)))
ELSE ''
END +
CASE
WHEN c.dimg <> 0 THEN
', G=' + CONVERT(varchar, cast(c.dimg AS decimal(18, 0)))
ELSE ''
END +
CASE
WHEN c.dimn <> 0 THEN
', N=' + CONVERT(varchar, cast(c.dimn AS decimal(18, 0)))
ELSE ''
END
AS Dimension,
min(DimA) AS DimA,
min(DimB) AS DimB,
min(DimC) AS DimC,
min(DimD) AS DimD,
min(DimE) AS DimE,
min(DimF) AS DimF,
min(DimG) AS DimG,
min(DimN) AS DimN,
min(Active) AS Active,
min(c.CreatedDtTm) AS CreatedDtTm,
min(createdby) as CreatedBy,
min(createdip) AS [CreatedIp],
min(UpdatedDtTm) as [UpdatedDtTm],
min(UpdatedBy) AS [UpdatedBy],
min(UpdatedIp) AS [UpdatedIp]
FROM bar_schedule_detail c
WHERE active = 1
AND barid = @BarId
GROUP BY
[TypeSize],
[ShapeCode] ,
CASE
WHEN dima <> 0 THEN
'A=' + CONVERT(varchar, cast(dima AS decimal(18, 0)))
ELSE ''
END +
CASE
WHEN dimb <> 0 THEN
', B=' + CONVERT(varchar, cast(dimb AS decimal(18, 0)))
ELSE ''
END +
CASE
WHEN dimc <> 0 THEN
', C=' + CONVERT(varchar, cast(dimc AS decimal(18, 0)))
ELSE ''
END +
CASE
WHEN dimd <> 0 THEN
', D=' + CONVERT(varchar, cast(dimd AS decimal(18, 0)))
ELSE ''
END +
CASE
WHEN dime <> 0 THEN
', E=' + CONVERT(varchar, cast(dime AS decimal(18, 0)))
ELSE ''
END +
CASE
WHEN dimf <> 0 THEN
', F=' + CONVERT(varchar, cast(dimf AS decimal(18, 0)))
ELSE ''
END +
CASE
WHEN dimg <> 0 THEN
', G=' + CONVERT(varchar, cast(dimg AS decimal(18, 0)))
ELSE ''
END +
CASE
WHEN dimn <> 0 THEN
', N=' + CONVERT(varchar, cast(dimn AS decimal(18, 0)))
ELSE ''
END
) as a, bar_schedule_detail b
where a.typesize = b.typesize
and a.shapecode = b.shapecode
and
(
CASE
WHEN b.dima <> 0 THEN
'A=' + CONVERT(varchar, cast(b.dima AS decimal(18, 0)))
ELSE ''
END +
CASE
WHEN b.dimb <> 0 THEN
', B=' + CONVERT(varchar, cast(b.dimb AS decimal(18, 0)))
ELSE ''
END +
CASE
WHEN b.dimc <> 0 THEN
', C=' + CONVERT(varchar, cast(b.dimc AS decimal(18, 0)))
ELSE ''
END +
CASE
WHEN b.dimd <> 0 THEN
', D=' + CONVERT(varchar, cast(b.dimd AS decimal(18, 0)))
ELSE ''
END +
CASE
WHEN b.dime <> 0 THEN
', E=' + CONVERT(varchar, cast(b.dime AS decimal(18, 0)))
ELSE ''
END +
CASE
WHEN b.dimf <> 0 THEN
', F=' + CONVERT(varchar, cast(b.dimf AS decimal(18, 0)))
ELSE ''
END +
CASE
WHEN b.dimg <> 0 THEN
', G=' + CONVERT(varchar, cast(b.dimg AS decimal(18, 0)))
ELSE ''
END +
CASE
WHEN b.dimn <> 0 THEN
', N=' + CONVERT(varchar, cast(b.dimn AS decimal(18, 0)))
ELSE ''
END
) = a.dimension
and a.CreatedDtTm = b.CreatedDtTm
and b.active = 1
and b.barid = @BarId
ORDER BY
substring(a.TypeSize,1,1) desc,
BarLength desc
END
END
水晶報表時,我如上面顯示調試代碼不顯示頁面。當我在我的Sql Server中執行代碼時,一切都正確執行。由於我在編程方面的知識有限。有人可以確定我面臨的問題嗎?
將數據類型從varchar更改爲nvarchar – Mahendra
@Mahendra更改值時仍存在同樣的問題。 我試過很多方法,如 和成員在(選擇MIN(成員)從BAR_SCHEDULE_DETAIL WHERE成員像'%[^ 0-9]%'和活動= 1和barid = @BarId)在where子句,但仍然不起作用。 它顯示的報告,但只有1個記錄,它更好,然後我得到一個錯誤消息的前一個問題。 –
只是提供樣本數據和所需的期望輸出。 – Mahendra