DECLARE @emailBody NVARCHAR(MAX);
SET @emailBody = N‘<style>table{table-layout:fixed;width:1200px;border:1px solid #000000;border-collapse:collapse;font-size:12px;empty-cells:show;}‘
- N‘th,td{border:1px solid #000000;padding:3px;}</style>‘
- N‘<H2>销退单</H2>‘ --标题
- N‘<table>‘ + N‘<thead><tr>‘
- N‘<th style="width:80px;">品号</th>‘
- N‘<th style="width:90px;">品名</th>‘
- N‘<th style="width:350px;">规格</th>‘
- N‘<th style="width:150px;">产品序列号</th>‘
- N‘<th style="width:80px;">数量</th>‘
- N‘<th style="width:80px;">退货原因</th>‘
- N‘</tr></thead><tbody>‘ --表头
- CAST(( SELECT c.ITEM_CODE AS td ,
‘‘ ,
b.ITEM_DESCRIPTION AS td ,
‘‘ ,
b.ITEM_SPECIFICATION AS td ,
‘‘ ,
b.UDF021 AS td ,
‘‘ ,
‘<div style="text-align:right;">‘- CAST(CAST(b.PRICE_QTY AS DECIMAL(20,
4)) AS VARCHAR(20)) - ‘</div>‘ AS td ,
‘‘ ,
b.REMARK AS td ,
‘‘
from SALES_RETURN a
left join SALES_RETURN_D b ON a.SALES_RETURN_ID = b.SALES_RETURN_ID
left join ITEM c ON b.ITEM_ID = c.ITEM_BUSINESS_ID
where DOC_NO = ‘2700-201809250001‘
FOR
XML PATH(‘tr‘) ,
TYPE
) AS NVARCHAR(MAX))
- CAST(CAST(b.PRICE_QTY AS DECIMAL(20,
- N‘</tbody></table>‘;
SELECT @emailBody = REPLACE(REPLACE(@emailBody,
‘<‘, ‘<‘),
‘>‘, ‘>‘);
select @emailBody
select c.ITEM_CODE,b.ITEM_DESCRIPTION,b.ITEM_SPECIFICATION,b.UDF021,b.PRICE_QTY, b.REMARK from SALES_RETURN a
left join SALES_RETURN_D b ON a.SALES_RETURN_ID = b.SALES_RETURN_ID
left join ITEM c ON b.ITEM_ID = c.ITEM_BUSINESS_ID
where DOC_NO = ‘2700-201809250001‘
原文地址:http://blog.51cto.com/13885809/2285780
时间: 2024-11-13 10:06:05