2013-03-22 2 views
0

ive를 보내는 날짜에 "T"문자를 제거하는 방법은 내 데이터베이스에서 쿼리 정보를 가져 오는 sp_send_dbmail을 만들었지 만 이제는 "T"가 표시된 날짜가 반환됩니다. 공간이 필요합니다.sp_send_dbmail (Transact-SQL)

나는 공간 Set @Body = Replace(@Body, '<TRRow>T</TRRow>', '') 으로 "T"를 대체하기 위해 시도했다 그러나 아무것도

도와주세요를 발생하지 않습니다! 명시 적으로 쿼리

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 

OUTPUT

2012-05-02T10:30:05.153 

답변

1

형식 날짜.

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) 
+0

매력처럼 작동합니다. :) 감사합니다! – ilse

관련 문제