透過系統預存程序 sp_makewebtask 可直接將查詢結果產生為 HTML 檔案,支援自訂樣板(TPL)排版。
EXECUTE sp_makewebtask
@outputfile = 'D:\alcatel\20030902\check.htm',
@query = 'SELECT * FROM Eiems_temporarydata..property',
@templatefile = 'D:\alcatel\20030902\check.TPL',
@dbname = 'EIEms_temporarydata',
@rowcnt = 0,
@whentype = 9,
@lastupdated = 1;
GO
<STYLE type="text/css">
body { font-size: 9pt; }
TH { FONT-SIZE: 12pt; }
TD { font-size: 12pt; }
</STYLE>
<CENTER>
<H1><FONT color="#000000">check it!</FONT></H1>
<HR>
<H2>
<TH><B>Size</B></TH>
<TH><B>Date</B></TH>
<TH><B>Name</B></TH>
<TH><B>Exist</B></TH>
<TH><B>Remark</B></TH>
<TH><B>result</B></TH>
<%begindetail%>
<%insert_data_here%>
<%insert_data_here%>
<%insert_data_here%>
<%insert_data_here%>
<%insert_data_here%>
<%insert_data_here%>
<%enddetail%>
</H2>
</CENTER>
<%begindetail%> / <%enddetail%>:定義資料列重複區塊。<%insert_data_here%>:對應查詢結果的每一欄位,順序需與 SELECT 清單一致。xp_cmdshell 相關權限,注意安全性風險。