1

データベースからクエリ情報を取得する sp_send_dbmail を作成しましたが、日付を返すと、スペースが必要な場所に「T」が表示されます。

「T」をスペースに置き換えようとしましたが、Set @Body = Replace(@Body, '<TRRow>T</TRRow>', '') 何も起こりません

助けてください !

Set @TableHead = '<html><head>' +
              '<H1 style="color: #000000">SpeedDail Lookup</H1>' +
              '<style>' +
              'td {border: solid black 1px;padding-left:5px;padding-right:5px;padding-top:1px;padding-bottom:1px;font-size:11pt;color:Black;} ' +
              '</style>' +
              '</head>' +
              '<body><table cellpadding=0 cellspacing=0 border=0>' +
              '<tr bgcolor=#F6AC5D>'+
              '<td align=center><b>Erf ID</b></td>' +
              '<td align=center><b>SpeedDail Base</b></td>' +
              '<td align=center><b>Contact No</b></td>' +
              '<td align=center><b>Indicator</b></td>' +   
              '<td align=center><b>Gate ID</b></td>' +
              '<td align=center><b>Is Deleted</b></td>' +
              '<td align=center><b>Insert Date</b></td>' +  
              '<td align=center><b>Update Date</b></td>' +                 
              '<td align=center><b>Person ID</b></td></tr>';

--Select information for the Report--   
Select @Body= (Select 
   ErfId           As [TD],
   SpeedDialBase   As [TD],
   ContactNo       As [TD],
   Indicator       As [TD],
   GateId          As [TD],
   IsDeleted       As [TD],
   InsertDate      As [TD],
   UpdateDate      As [TD],
   PersonId        As [TD]
FROM [DB].[dbo].[SpeedDialLookup]

For XML raw('tr'), Elements)

-- Replace the entity codes and row numbers
Set @Body = Replace(@Body, '_x0020_', space(1))
Set @Body = Replace(@Body, '_x003D_', '=')
Set @Body = Replace(@Body, '<tr><TRRow>1</TRRow>', '<tr bgcolor=#C6CFFF>')
Set @Body = Replace(@Body, '<TRRow>0</TRRow>', '')


Set @Body = @TableHead + @Body + @TableTail

出力

2012-05-02T10:30:05.153
4

1 に答える 1

2

クエリで日付を明示的にフォーマットします。

Select @Body= (Select 
   ErfId           As [TD],
   SpeedDialBase   As [TD],
   ContactNo       As [TD],
   Indicator       As [TD],
   GateId          As [TD],
   IsDeleted       As [TD],
   convert(nvarchar, InsertDate, 121)      As [TD],
   convert(nvarchar, UpdateDate, 121)      As [TD],
   PersonId        As [TD]
FROM [DB].[dbo].[SpeedDialLookup]
For XML raw('tr'), Elements)
于 2013-03-22T07:08:36.730 に答える