gpt4 book ai didi

html - 如何在 SQL+HTML 脚本生成的电子邮件中左对齐列条目

转载 作者:行者123 更新时间:2023-11-28 15:21:01 26 4
gpt4 key购买 nike

我正在使用 SQL+HTML 脚本发送包含表 mytable 前 5 列的电子邮件。目前,我使用 [th][td] 分别将所有列标题居中对齐并且每个列条目向右对齐。如何使 Vendor 列中的条目左对齐,同时保持其他所有内容相同?

  DECLARE @dt datetime, @prev_dt datetime      
SELECT @dt = dbo.GetDateOnly(getdate())
SELECT @prev_dt = dbo.GetDateOnly(getdate()-1)

SELECT top 5
Vendor,
OUTL_New_$,
OUTL_Old_$,
Outl_Diff_$ ,
OUTL_Diff_Perc,
Analyst
into #vpositive
FROM mytable
ORDER BY 4 DESC
--select * from #vpositive

if(@@ROWCOUNT>0)
begin
--drop table #email
DECLARE @Body2 varchar(max)
declare @TableHead2 varchar(max)
declare @TableTail varchar(max)
Set @TableTail = '</table></body></html>';

Set @TableHead2 = '<html><head>' +
'<hr style="height:1px;border:none;color:#333;background-color:#333;">'+
'<H5 style="color: #000000; font-family:Arial">2: VENDOR LEVEL TOP 5 OUTL $ <font color="blue">INCREMENTS -</font></H5>' +
'<style>' +

'td {border: solid black 1px;padding-left:5px;padding-right:5px;padding-top:1px;padding-bottom:1px;font-size:10pt;color:Black;text-align:right;font-family:Arial;} ' +
'th {border: solid black 1px;padding-left:5px;padding-right:5px;padding-top:1px;padding-bottom:1px;font-size:10pt;color:Black;text-align:center;font-family:Arial;} ' +

'</style>' +

'</head>' +
'<body><table cellpadding=0 cellspacing=0 border=0 width=auto>' +


'<tr bgcolor=#007336>'+
'<th><b><font color="white">Vendor</font></b></th>' +
'<th><b><font color="white">OUTL$ New</font></b></th>' +
'<th><b><font color="white">OUTL$ Old</font></b></th>' +
'<th><b><font color="white">OUTL$ Diff</font></b></th>' +
'<th><b><font color="white">OUTL$ Diff Perc</font></b></th>' +
'<th><b><font color="white">Analyst</font></b></th></tr>';

--Select information for the Report--
Select @Body2= (select
substring(Vendor,1,60) As [TD]
,'$ '+substring(parsename(convert(varchar,convert(money,cast(OUTL_New_$ as int)),1),2),1,13) As [TD]
,'$ '+substring(parsename(convert(varchar,convert(money,cast(OUTL_Old_$ as int)),1),2),1,13) As [TD]
,'$ '+substring(parsename(convert(varchar,convert(money,cast(OUTL_Diff_$ as int)),1),2),1,13) As [TD]
,substring(CAST(OUTL_Diff_Perc AS varchar(10)),1,4)+' %' As [TD]
,substring(Analyst,1,20) As [TD]

from #vpositive
For XML raw('tr'), Elements)

Set @Body = @TableHead2 + @Body2 + @TableTail

--Email
EXEC msdb.dbo.sp_send_dbmail
@recipients='abc@abc.com',
@subject = My analysis',
@body = @Body,
@body_format = 'HTML';
end

最佳答案

你试过吗:

<th align="left">

或者这个:

text-align: left;

关于html - 如何在 SQL+HTML 脚本生成的电子邮件中左对齐列条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34912299/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com