千家信息网

SQL Server 2008 自动发邮件HTML表格

发表于:2024-12-03 作者:千家信息网编辑
千家信息网最后更新 2024年12月03日,DECLARE @emailBody NVARCHAR(MAX);SET @emailBody = N'table{table-layout:fixed;width:1200px;border:1px
千家信息网最后更新 2024年12月03日SQL Server 2008 自动发邮件HTML表格

DECLARE @emailBody NVARCHAR(MAX);
SET @emailBody = N''

  • N'

    销退单

    ' --标题
  • N'' + N''
  • N'
  • '
  • N'
  • '
  • N'
  • '
  • N'
  • '
  • N'
  • '
  • N'
  • '
  • N'
  • ' --表头
  • CAST(( SELECT c.ITEM_CODE AS td ,
    '' ,
    b.ITEM_DESCRIPTION AS td ,
    '' ,
    b.ITEM_SPECIFICATION AS td ,
    '' ,
    b.UDF021 AS td ,
    '' ,
    '
    '
    • CAST(CAST(b.PRICE_QTY AS DECIMAL(20,
      4)) AS VARCHAR(20))
    • '
    ' 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))
  • N'

  • 品号品名规格产品序列号数量退货原因
    ';

    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'

    0